modal windows (again)
modal windows (again)
- Subject: modal windows (again)
- From: Devon E Bowen <email@hidden>
- Date: Tue, 9 Mar 2004 05:32:35 -0500 (EST)
I asked about this problem and didn't get an answer. Now I have a bit
more info. The mystery has deepened.
Basically, I'm simply trying to make an non-blocking alert panel. I
do the following:
panel = NSGetAlertPanel(title, msg, defButton, altButton, otherButton);
then I set up the action/target for the buttons in this panel with a
recursive function I'll attach to the end of this email. And then do
session = [NSApp beginModalSessionForWindow:panel];
Now, I just go back to the event loop. Note that I do not ever make
a call to runModalSession. Yet the target is called when the button
is pressed anyway. The Apple docs clearly say:
When you invoke [runModalSession], events for the NSWindow of this
session are dispatched as normal. This method returns when there
are no more events. You must invoke this method frequently enough
that the window remains responsive to events.
So I would expect to have to run this method inside of a timer that
goes of frequently or something. But apparently, this isn't really
how it works. Can someone explain this? I'm getting desparate.
Devon
-------------------
// a recursive method to look for and set a button target/action.
-(void)linkButtonInView:(NSView*)view withTitle:(NSString*)title toSelector:(SEL)selector
{
if ([[view class] isSubclassOfClass:[NSButton class]]) {
NSButton *button = (NSButton*) view;
if ([[button title] isEqualToString:title]) {
[button setTarget:self];
[button setAction:selector];
}
} else {
NSArray *subviews = [view subviews];
int i;
for (i=0; i<[subviews count]; i++)
[self linkButtonInView:[subviews objectAtIndex:i] withTitle:title toSelector:selector];
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.