Re: 10.5 Only: If I say NO, NSOutlineView ignores cmd key, does its own thing
Re: 10.5 Only: If I say NO, NSOutlineView ignores cmd key, does its own thing
- Subject: Re: 10.5 Only: If I say NO, NSOutlineView ignores cmd key, does its own thing
- From: Jerry Krinock <email@hidden>
- Date: Wed, 4 Jun 2008 19:29:11 -0700
On 2008 Jun, 04, at 16:39, Corbin Dunn wrote:
It sounds like you think it is incorrect to have NSTableView handle
cmd-up/down like plain up/down. Please log a bug for this; I'll
consider changing it.
No, I was just asking. I don't have any religion on this. However,
It doesn't stop doing stuff if cmd is down; in fact, it never has.
I just filed a documentation "wasn't helpful" on the behavior of
NSTableView keyboard equivalents/keyDowns/whatever being undocumented
[1].
You can work around it by overriding -keyDown: in a nstableview
subclass and not calling super if it is cmd + (up/down).
My Business Manager says that your workaround [2] is good enough. And
faster :)
Thank you, Corbin. Case closed.
Jerry
[1] http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/Concepts/AboutTables.html#/
/apple_ref/doc/uid/20000115-CJBCADCE
The document is missing information.
This documentation does not state what keyboard equivalents or other
keystrokes execute what actions in NSTableView. For example, the up/
down arrow keys move the selection. "Everyone" knows that, of course,
but what if you hold down the cmd key while hitting up/down arrow
key? The answer is that the same thing happens, but not everyone
knows that, and cannot know without running an experiment on an app
that is known to not implement its own key equivalent for this. It is
necessary to know this when designing applications that seek to use
these keystrokes for their own actions, particularly in Leopard since
disabled key equivalents in NSMenu are now "passed through"; see http://developer.apple.com/releasenotes/Cocoa/AppKit.html#NSMenu
. Without knowing this, the same keystroke can result in different
actions if the first action in the chain is disabled.
[2]
- (void)keyDown:(NSEvent*)event {
NSString *s = [event charactersIgnoringModifiers] ;
unichar keyChar = 0 ;
BOOL didDo = NO ;
if ([s length] == 1) {
...
// handle other keys as desired, set didDo if did do
...
}
int unsigned modifierFlags = [[NSApp currentEvent] modifierFlags] ;
BOOL cmdKeyDown = (modifierFlags & NSCommandKeyMask) > 0 ;
if (!didDo && !cmdKeyDown) {
[super keyDown:event] ;
}
else if (cmdKeyDown) {
NSBeep() ;
}
}
_______________________________________________
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