kTISPropertyUnicodeKeyLayoutData Returns NULL
kTISPropertyUnicodeKeyLayoutData Returns NULL
- Subject: kTISPropertyUnicodeKeyLayoutData Returns NULL
- From: Joe Turner <email@hidden>
- Date: Tue, 25 Aug 2009 13:42:12 -0500
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 (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