On Mar 4, 2014, at 11:28 AM, Mills, Steve <[email protected]> wrote:

> On Mar 4, 2014, at 13:03:34, Mills, Steve <[email protected]> wrote:
> 
>> I'm seeing something really odd. We get the NSEvent for the current keyDown 
>> when the user types an unmodified space. From that we get the eventRef to 
>> pass to some legacy code. Sometimes that EventRef will contain the correct 
>> space character (32) in kEventParamKeyMacCharCodes and the correct space 
>> character (32) in kEventParamKeyUnicodes. Other times it will pass back an 
>> INcorrect 0-value for kEventParamKeyMacCharCodes (and return noErr) and 
>> generate error -9870 (eventParameterNotFoundErr) for kEventParamKeyUnicodes. 
>> In both cases the kEventParamKeyCode will be correct (49). In all cases, the 
>> NSEvent contains the correct space character.
>> 
>> Any ideas why NSEvent is creating an incorrect EventRef under some 
>> circumstances but not others? In our app, switching tools causes the 
>> different results, which will swap in/out tool-specific menus in the 
>> menubar. None of the menus use modified or unmodified space as a key equiv.
> 
> Weird. If I set a breakpoint in our app's sendEvent handler and get the 
> eventRef, it contains the correct key char and uni char. But by the time the 
> NSEvent's _eventRef is NULL (so I guess NSApplication has duplicated the 
> NSEvent but not the EventRef when we pass it to super), and then getting the 
> eventRef from that version of the NSEvent produces the bad key char and uni 
> char. This is getting more mysterious.

A little architectural background first: normally, when a keyboard event first 
arrives in the HIToolbox event queue from the window server, the initial 
contents are just as you saw - a keycode and key modifiers, but no unicode 
values. The unicode text doesn’t get added until later when the key event is 
put into the event queue and the Text Services Manager takes a look at it and 
processes the key event through the active input method. 

In this case, if the NSEvent needs to cons up an EventRef from its own data, it 
probably just creates a kEventRawKeyDown with keycode but nothing else. No 
unicode text is added because the event isn’t seen by TSM.

-eric


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to