Skip navigation.
 
mlRe: Converting keyCode&modifierFlags to NSString
FROM : Jonathan Grynspan
DATE : Tue Aug 01 18:16:15 2006

If there is a method for this specific case, I'm not aware of it, but 
it wouldn't be hard to add a category to NSEvent to do what you're 
looking for.

It's possible that the actions you want to perform actually belong 
elsewhere. For instance, pressing the delete key usually implies you 
want to delete something (ORLY!), and if you're working on a custom 
NSView subclass, the method to implement would be -(IBAction)delete: 
(id)sender, which by virtue of being implemented would automagically 
enable a Delete menu item in the Edit menu, etc. etc. The same for -
scrollUp:, -scrollDown:, and a number of other methods declared (but 
not implemented by default) for NSResponder and NSView.

-Jonathan Grynspan

On 1-Aug-06, at 11:51 AM, Fabian Schuiki wrote:

> Thanks, haven't seen them when I was going trough NSEvent!
> So there's no function that does stuff like that automatically? 
> I'll have a look at that unichar enum.
>
> Thanks a lot,
> Fabian
>
> Fabian Schuiki
> <email_removed>
> CEO
>
>
> Am 01.08.2006 um 17:38 schrieb Jonathan Grynspan:
>

>> Take a look at the enums near the bottom of NSEvent.h. They 
>> include unichar values for most function/control keys. Compare 
>> them to the first character in the result of -characters or -
>> charactersIgnoringModifiers:
>>
>> if ([[anEvent characters] length] > 0 && [[anEvent characters] 
>> characterAtIndex: 0] == NSDeleteFunctionKey) {
>>     /* do stuff here */
>> }
>>
>> -Jonathan Grynspan
>>
>> On 1-Aug-06, at 11:32 AM, Fabian Schuiki wrote:
>>

>>> I already use them, but there are several special characters for 
>>> Keys like Escape, Backspace, Delete, Arrows etc.
>>>
>>> Best,
>>> Fabian
>>>
>>> Fabian Schuiki
>>> <email_removed>
>>> CEO
>>>
>>>
>>> Am 01.08.2006 um 16:57 schrieb Jonathan Grynspan:
>>>

>>>> Take a look at the -characters and -charactersIgnoringModifiers 
>>>> messages belonging to NSEvent. They should do what you're 
>>>> looking for. :)
>>>>
>>>> -Jonathan Grynspan
>>>>
>>>> On 1-Aug-06, at 9:19 AM, Fabian Schuiki wrote:
>>>>

>>>>> Hi,
>>>>>
>>>>> Is it somehow possible to convert an NSEvent's keyCode and 
>>>>> modifierFlags to an NSString, containing a representation of 
>>>>> that keyCode and modifierFlags, such as the keyEquivalent 
>>>>> representation in an NSMenuItem?
>>>>> This has to be possible, hasn't it?
>>>>>
>>>>> Best Regards,
>>>>> Fabian Schuiki
>>>>>
>>>>> Fabian Schuiki
>>>>> <email_removed>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> MacOSX-dev mailing list
>>>>> <email_removed>
>>>>> http://www.omnigroup.com/mailman/listinfo/macosx-dev

>>>>
>>>> _______________________________________________
>>>> MacOSX-dev mailing list
>>>> <email_removed>
>>>> http://www.omnigroup.com/mailman/listinfo/macosx-dev

>>>
>>> _______________________________________________
>>> MacOSX-dev mailing list
>>> <email_removed>
>>> http://www.omnigroup.com/mailman/listinfo/macosx-dev

>>

>
> _______________________________________________
> MacOSX-dev mailing list
> <email_removed>
> http://www.omnigroup.com/mailman/listinfo/macosx-dev

Related mailsAuthorDate
mlConverting keyCode&modifierFlags to NSString Fabian Schuiki Aug 1, 15:19
mlRe: Converting keyCode&modifierFlags to NSString Jonathan Grynspan Aug 1, 16:57
mlRe: Converting keyCode&modifierFlags to NSString Fabian Schuiki Aug 1, 17:32
mlRe: Converting keyCode&modifierFlags to NSString Fabian Schuiki Aug 1, 17:51
mlRe: Converting keyCode&modifierFlags to NSString Jonathan Grynspan Aug 1, 18:16
mlRe: Converting keyCode&modifierFlags to NSString Fabian Schuiki Aug 1, 18:20