2013-08-19 1 views
0

Я пытаюсь показать 2 листа (панели) один за другим. Тем не менее, похоже, что на первом листе не хватает времени, чтобы закрыть до появления второго - так что это заканчивается в довольно беспорядке.Показаны 2 листа/панели - один-после-другого

Вот мой код ...

Макросы

#define DRK_ALERT_YESNO_SHOW(X,Y,W) \ 
NSAlert* yesnoAlert = [NSAlert alertWithMessageText:X \ 
defaultButton:@"Yes" \ 
alternateButton:@"No" \ 
otherButton:nil \ 
informativeTextWithFormat:Y]; \ 
[yesnoAlert beginSheetModalForWindow:[[NSApp delegate] window] \ 
modalDelegate:self \ 
didEndSelector:W \ 
contextInfo:nil]; 

// Open File Sheet 

#define DRK_OPENFILE_SHEET_BEGIN(X,Y,Z,A) NSOpenPanel *openPanel = [NSOpenPanel openPanel];\ 
[openPanel setAllowsMultipleSelection: NO];\ 
[openPanel setCanChooseDirectories:NO];\ 
[openPanel setCanCreateDirectories:NO];\ 
[openPanel setCanChooseFiles:YES];\ 
[openPanel setShowsHiddenFiles:YES];\ 
[openPanel setPrompt:Y];\ 
[openPanel setAllowedFileTypes:A];\ 
[openPanel beginSheetModalForWindow:X completionHandler:^(NSInteger result) {\ 
    if (result == NSFileHandlingPanelOKButton) {\ 
     NSString* Z = [openPanel filename]; 

#define DRK_OPENFILE_SHEET_END }\ 
}]; 

Фактический код

- (IBAction)openDo:(id)sender { 

    DRK_ALERT_YESNO_SHOW(@"Are you sure you want to discard changes?", 
         @"You may lose any changes you have made to your current projects.", 
         @selector(shouldOpenDo:code:context:)); 

} 

- (void)shouldOpenDo:(NSAlert*)alert code:(int)choice context:(void *)context 
{ 
    if (choice==NSAlertDefaultReturn) 
    { 
     DRK_OPENFILE_SHEET_BEGIN(([[NSApp delegate] window]), @"Open Project", filename,(@[@"txt"])); 

     // Yep, we can now open the file: filename 

     DRK_OPENFILE_SHEET_END 
    } 
    else 
    { 
     // nope, don't open anything 
    } 
} 

Любые идеи?

ответ

0

ОК, так что это все, что потребовалось:

[[alert window] orderOut:nil]; 

непосредственно перед DRK_OPENFILE_SHEET_BEGIN.