NSApplication Bug or Feature: Keystroking -performClose closes all windows?
NSApplication Bug or Feature: Keystroking -performClose closes all windows?
- Subject: NSApplication Bug or Feature: Keystroking -performClose closes all windows?
- From: DumberThanDanQuayle <email@hidden>
- Date: Fri, 18 Feb 2005 17:44:24 -0500
NSApplication Bug or Feature: Keystroking -performClose closes all
windows?
Setting a menuItem in InterfaceBuilder to either directly call
-performClose on the first responder or indirectly call -performClose
on a window by using an intermediate object and method, such as
[MyWindowContoller closeWindow:] in the stack trace below, works fine
when simply using the mouse to select that menuItem. That is, as
expected, only main window closes when using the mouse.
But if a keystroke is used to activate the command, NSApplication
intervenes and closes all windows by calling
-makeWindowPerform:@selector(_batchClose) ... . This is demonstrated
in this stack trace:
#8 0x93154100 in -[NSWindow _batchClose]
#9 0x92e90478 in -[NSApplication makeWindowsPerform:inOrder:]
#10 0x92f356e4 in -[_NSThemeWidget optionClick:]
#11 0x92f6f568 in -[_NSThemeWidget performClick:]
#12 0x002a09a0 in -[MyWindowContoller closeWindow:]
#13 0x92e78224 in -[NSApplication sendAction:to:from:]
#14 0x92eada44 in -[NSMenu performActionForItemAtIndex:]
#15 0x92ef22e4 in -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:]
#16 0x92ef8c14 in -[NSMenu performKeyEquivalent:]
#17 0x92ed7ccc in -[NSApplication _handleKeyEquivalent:]
#18 0x92df53dc in -[NSApplication sendEvent:]
#19 0x92dfdc54 in -[NSApplication run]
#20 0x92eba2b8 in NSApplicationMain
#21 0x002fcf74 in main at main.m:13
So, it clear that this behavior is specifically coded for in
[NSApplication _handleKeyEquivalent]. Furthermore, if an intermediate
object and method is used as the first responder, such as
[MyWindowContoller closeWindow:] in the stack trace above, setting the
"sender" to nil or self when forwarding the -performClose: to the
window does not affect this problem.
This issue is easy to work around, simply call if([[window delegate]
shouldWindowClose]) [self close] in [MYWindowController closeWindow].
But is this really suppose to an NSApplication "feature," or is it bug,
or am I missing something like a way to this "feature" off, perhaps
through an NSApplication delegate method?
~ George
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden