Hey,

So, to translate from a string to a keycode, I've been using the UCKeyboardLayout. But, on some keyboard layouts (only Japanese so far), I get a NULL pointer for the layout, and then the app crashes.

Here's the code:
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);

The third line is where it will crash, I assume because I am passing NULL into the CFDataGetBytePtr().

In reading the documentation, it seems that the value of property "kTISPropertyUnicodeKeyLayoutData" only returns NULL if there is no layout data, or if the data is KCHR. So, do these users somehow have KCHR keyboard layouts? If so, it seems apple has depricated any methods that could be used to get the data and then keycodes from a KCHR resource. So, is there any way around this?

Cheers,

Joe
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com

Reply via email to