• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGEventKeyboardGetUnicodeString + modifier key
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: CGEventKeyboardGetUnicodeString + modifier key
      • From: Eric Schlegel <email@hidden>
References: 
 >Re: CGEventKeyboardGetUnicodeString + modifier key (From: email@hidden)
 >Re: CGEventKeyboardGetUnicodeString + modifier key (From: Eric Schlegel <email@hidden>)

  • Prev by Date: Re: taking control of the Window menu
  • Next by Date: Document based apps & tabbed windows?
  • Previous by thread: Re: CGEventKeyboardGetUnicodeString + modifier key
  • Next by thread: Re: CGEventKeyboardGetUnicodeString + modifier key
  • Index(es):
    • Date
    • Thread