Re: NSDeleteCharacter when expected NSBackspaceCharacter
Re: NSDeleteCharacter when expected NSBackspaceCharacter
- Subject: Re: NSDeleteCharacter when expected NSBackspaceCharacter
- From: "Sean McBride" <email@hidden>
- Date: Mon, 16 May 2005 15:50:25 -0400
- Organization: Rogue Research
On 2005-05-13 11:28, j o a r said:
>- (void) keyDown:(NSEvent *) event
>{
> unichar key = [[event charactersIgnoringModifiers]
>characterAtIndex: 0];
>
> NSLog(@"DeleteChar: %d, BackspaceChar: %d, DeleteFunctionKey: %
>d", (key == NSDeleteCharacter), (key == NSBackspaceCharacter), (key
>== NSDeleteFunctionKey));
>}
>
>Hit backspace (surprising result):
>2005-05-13 11:15:49.151 MyApp[4925] DeleteChar: 1, BackspaceChar: 0,
>DeleteFunctionKey: 0
>
>Hit delete (mostly expected result):
>2005-05-13 11:16:00.044 MyApp[4925] DeleteChar: 0, BackspaceChar: 0,
>DeleteFunctionKey: 1
Those constant names are very confusing! I've never seen a Mac keyboard
with a 'backspace' key, but I'm guessing NeXTs did have them. Anyway, I
think you may be confusing 'keys' and 'characters'.
I notice that the following are in NSEvent.h:
NSDeleteFunctionKey, NSDeleteCharFunctionKey, NSDeleteLineFunctionKey
and the following are in NSText.h:
NSBackspaceCharacter, NSDeleteCharacter
I think keys map to chars (and this depends on the user's keybindings!)
NSEvent docs show:
NSDeleteFunctionKey = Forward Delete key
NSDeleteCharFunctionKey = Delete Character key. Not on most Macintosh
keyboards
NSDeleteLineFunctionKey = Delete Line key. Not on most Macintosh keyboards
There doesn't seem to be a "...Key" constant for the backspace key.
NSText docs show:
NSBackspaceCharacter = The backspace character: 0x0008
NSDeleteCharacter = The delete character: 0x007f
Maybe your NSTableView subclass can implement deleteBackward: and
deleteForward: instead? I think that would be best. Otherwise testing
chars is probably better than testing raw keys.
But I'm not sure about any of this, but no one else replied. :)
PS, have you noticed the newest US Apple keyboards on the G5 use the word
'delete' on BOTH the backspace and del keys!!! Raskin is rolling around
in his grave no doubt. :(
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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