views:

74

answers:

1

My Qt app supports changing input language on Linux and Windows. I want to add support for changing input language on MAC OSX, too.
But unfortunately I don't have any information about MAC SDK. (My first and last work with MAC OSX was compiling Qt and compiling my app!)
I googling this problem and found that I need to using Text Input Source Services and also I found these codes:

TISInputSourceRef isref;
isref = TISCopyCurrentKeyboardInputSource();
CFDataRef uchr = (CFDataRef) TISGetInputSourceProperty(isref
                                 , kTISPropertyUnicodeKeyLayoutData);

UCKeyboardLayout * keyLayoutPtr=(UCKeyboardLayout*)CFDataGetBytePtr(uchr);

Is keyLayoutPtr a pointer for current keyboard layout?
if answer of above question is yes then, what do I should compare vs. keyLayoutPtr?
in the other words, how can I find that the current keyboard layout is for example "English" or is not? (one thing like as LANG_ENGLISH in Win API or us in XLib).
Any help and idea is appreciated.

+1  A: 

I think you'd pass isref to TISGetInputSourceProperty, using the key kTISPropertyInputSourceLanguages, and check whether the first language code in the array is "en" or something like that. I don't know if it will return just "en" or "en-US" etc.

JWWalker