Re: NSApplication Bug or Feature: Keystroking -performClose closes all windows?
Re: NSApplication Bug or Feature: Keystroking -performClose closes all windows?
- Subject: Re: NSApplication Bug or Feature: Keystroking -performClose closes all windows?
- From: DumberThanDanQuayle <email@hidden>
- Date: Sun, 20 Feb 2005 13:19:15 -0500
Please disregard my original post, as I am now keystroking
-performClose with Command-w and it performs as expected, only one
window closes.
I believe that I was inadvertently testing my -performClose keystroke
on a "project" window that is supposed to close all the other windows
in my application.
On Feb 18, 2005, at 5:44 PM, DumberThanDanQuayle wrote:
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:
email@hidden
This email sent to email@hidden
_______________________________________________
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