osx - How to change the Mac OS X Keyboard Layout programmatically? -
my qt app supports changing input language on linux , windows. want add support changing input language in mac osx, too.
unfortunately don't have information mac sdk. (my first , last work os x compiling qt , compiling app!)
i googling problem , found need use text input source services , found these codes:
tisinputsourceref isref; isref = tiscopycurrentkeyboardinputsource(); cfdataref uchr = (cfdataref)tisgetinputsourceproperty(isref, ktispropertyunicodekeylayoutdata); uckeyboardlayout * keylayoutptr=(uckeyboardlayout*)cfdatagetbyteptr(uchr);
is keylayoutptr
pointer current keyboard layout?
if answer above question "yes", should compare keylayoutptr
?
in other words, how can check if current keyboard layout (for example) "english"? (or lang_english
in win api or us
in xlib.)
i think you'd pass isref
tisgetinputsourceproperty
, using key ktispropertyinputsourcelanguages
, , check whether first language code in array "en" or that. don't know if return "en" or "en-us" etc.
Comments
Post a Comment