Re: CGEventKeyboardGetUnicodeString + modifier key
Re: CGEventKeyboardGetUnicodeString + modifier key
- Subject: Re: CGEventKeyboardGetUnicodeString + modifier key
- From: Bill <email@hidden>
- Date: Sun, 15 Apr 2007 21:32:46 -0700
On Apr 15, 2007, at 8:27 PM, Eric Schlegel wrote:
On Apr 15, 2007, at 12:36 PM, email@hidden wrote:
UCKeyTranslate() seems to work fine for a single key, but what
about a two-key operation, something like option-u u to produce ΓΌ?
UCKeyTranslate keeps track of the dead key state (a dead key is
option-u, for example, which doesn't produce a character code until
you type something else to complete the key combination) in the
deadKeyState output parameter. You should keep a global variable
for the dead key state and pass a pointer to that same variable on
each call, and that will allow UCKeyTranslate to track the dead key
state from one invocation to the next.
Note that this approach still isn't going to work for input that
passes through a more complex input method such as Kotoeri for
Japanese input, but maybe that's OK for your target market.
-eric
I did as you suggested, but I can't seem to get anything in the
deadKeyState variable. I'm using a CGEventTapCallBack function which
looks mostly like this:
static UCKeyboardLayout *uchrData; // this is set elsewhere...
static UInt32 deadKeyState = 0;
CGEventRef eventTapFunction(CGEventTapProxy proxy, CGEventType type,
CGEventRef event, void *refcon)
{
UniCharCount maxStringLength = 1;
UniCharCount actualStringLength;
UniChar chars[0];
CGEventKeyboardGetUnicodeString( event, maxStringLength,
&actualStringLength, chars );
CGEventFlags flags = CGEventGetFlags ( event );
UInt16 keycode = CGEventGetIntegerValueField( event,
kCGKeyboardEventKeycode );
OSStatus err = UCKeyTranslate( uchrData, keycode,
kUCKeyActionDisplay, flags, LMGetKbdType(),
1, &deadKeyState, maxStringLength, &actualStringLength, chars );
...
}
I've tried changing the values of the input variables somewhat, but
deadKeyState is always 0. Any hints as to what I may be doing wrong?
Thanks,
Bill
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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