Toolbar validation and modal panel
Toolbar validation and modal panel
- Subject: Toolbar validation and modal panel
- From: Bruno Berisso <email@hidden>
- Date: Mon, 10 Jan 2011 12:48:02 -0200
Hello all.
In my application I use a modal sheet for block the user interface while the app is consulting a remote service. The call to the service is executed in background and the sheet is show/hide with two methods defined in the application
delegate 'showLoading' and 'hideLoading'. Those are:
- (void)showLoading {
[self performSelectorOnMainThread:@selector(showLoadingPanelAction) withObject:nil waitUntilDone:NO];
}
- (void)showLoadingPanelAction {
if (!self.loadingPanel) {
self.loadingPanel = [[LoadingViewController alloc] init];
[self.loadingPanel showInWindow:[NSApp mainWindow]];
}
}
- (void)hideLoading {
[self performSelectorOnMainThread:@selector(hideLoadingPanelAction) withObject:nil waitUntilDone:NO];
}
- (void)hideLoadingPanelAction {
if (self.loadingPanel) {
[loadingPanel dismissModal];
[loadingPanel release];
loadingPanel = nil;
}
}
The LoadingViewController : SheetController class:
- (void)showInWindow:(NSWindow *)mainWindow {
sheetWindow = [self window];
[self sheetWillShow];
[NSApp beginSheet:sheetWindow modalForWindow:mainWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
[NSApp runModalForWindow:sheetWindow];
[NSApp endSheet:sheetWindow];
[sheetWindow orderOut:self];
}
- (void)dismissModal {
[sheetWindow close];
[NSApp stopModal];
}
For some reason when the sheet end all the toolbar items are disabled no matter what value return the 'validateToolbarItems' method.
If i debug the calls made to 'setEnabled' of my NSToolbarItems the last call stack looks like this:
#0 0x10002d3e0 in -[NSToolbarItems(Debug) setEnabled:] at ActionsController.m:30
#1 0x7fff87b321a4 in -[NSToolbarItem setEnabled:]
#2 0x7fff88075b77 in -[NSToolbarItem _restoreToolbarItemAfterSheet]
#3 0x7fff81639153 in -[NSArray makeObjectsPerformSelector:]
#4 0x7fff85dc2a66 in _nsnote_callback
#5 0x7fff81621000 in __CFXNotificationPost
#6 0x7fff8160d578 in _CFXNotificationPostNotification
#7 0x7fff85db99ce in -[NSNotificationCenter postNotificationName:object:userInfo:]
#8 0x7fff87d191dc in -[NSWindow(NSSheets) _detachSheetWindow]
#9 0x7fff87d18ef5 in -[NSMoveHelper(NSSheets) _closeSheet:andMoveParent:]
#10 0x7fff87d18c75 in -[NSWindow(NSSheets) _orderOutRelativeToWindow:]
#11 0x7fff87acddf6 in -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
#12 0x7fff87acd77a in -[NSWindow orderWindow:relativeTo:]
#13 0x7fff87c7f924 in -[NSWindow _close]
#14 0x100018ac5 in -[SheetController dismissModal] at SheetController:32
#15 0x100001c82 in -[TestAppDelegate hideLoadingPanelAction] at TestAppDelegate:158
#16 0x7fff85dda44f in __NSThreadPerformPerform
#17 0x7fff816162ad in __CFRunLoopDoSources0
#18 0x7fff816145f9 in __CFRunLoopRun
#19 0x7fff81613dbf in CFRunLoopRunSpecific
#20 0x7fff8693393a in RunCurrentEventLoopInMode
#21 0x7fff8693373f in ReceiveNextEventCommon
#22 0x7fff869335f8 in BlockUntilNextEventMatchingListInMode
#23 0x7fff87ad5e64 in _DPSNextEvent
#24 0x7fff87ad57a9 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#25 0x7fff87d10c47 in -[NSApplication _realDoModalLoop:peek:]
#26 0x7fff87d0e7d5 in -[NSApplication runModalForWindow:]
#27 0x100018a31 in -[SheetController showInWindow:] at SheetController:26
#28 0x100001973 in -[TestAppDelegate showLoadingPanelAction] at TestAppDelegate:125
#29 0x7fff85dda44f in __NSThreadPerformPerform
#30 0x7fff81616401 in __CFRunLoopDoSources0
#31 0x7fff816145f9 in __CFRunLoopRun
#32 0x7fff81613dbf in CFRunLoopRunSpecific
#33 0x7fff8693393a in RunCurrentEventLoopInMode
#34 0x7fff8693369d in ReceiveNextEventCommon
#35 0x7fff869335f8 in BlockUntilNextEventMatchingListInMode
#36 0x7fff87ad5e64 in _DPSNextEvent
#37 0x7fff87ad57a9 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#38 0x7fff87a9b48b in -[NSApplication run]
#39 0x7fff87a941a8 in NSApplicationMain
#40 0x100001299 in main at main.m:13
The question is, what i'm doing wrong? how can i fix this issue?
Thanks for your time.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden