Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: SendTextInputEvent returns eventNoHandledErr (-9874) with kEventTextInputUnicodeText type event
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SendTextInputEvent returns eventNoHandledErr (-9874) with kEventTextInputUnicodeText type event



Brad,
You're passing the CFString 'str' instead of a pointer to UniChars in your call to SetEventParameter(.. kEventParamTextInputSendText, typeUnicodeText...)
You may also want to use 'kEventAttributeUserEvent' instead of 'kEventAttributeNone' in your call to CreateEvent().

Alternatively, check out CGEventKeyboardSetUnicodestring() in CGEvent.h (available since Tiger).  This flags the Unicode text so that when the key-focus process gets the CG event, instead of posting a raw key event to the Carbon event queue, a kEventTextInputUnicodeText event is dispatched instead via SendTextInputEvent() (with all the correct goodness)... seems more convenient if you're already using CGRemote.

Michael Grady

On Jun 22, 2007, at 4:40 PM, Bradford Werner wrote:

The entries I found in the archives didn't answer my question... I'm hoping that this isn't too basic of a question or been answered previous. In any event, I'd definitely appreciate some guidance or better yet, an example! :)

I'm trying to have an application generate Unicode input to OSX apps like Character Palette and Ink do. Right now my app is using CGPostKeyboardEvent() and that's great when I know a key mapping...

But now I need to generate Unicode characters into the input stream which may not be in any current (or existing) Keyboard Layout. How does Character Palette do this? I'm under the assumption that I don't have to register a handler, and that the kEventTextInputUnicodeText event will be handled by a system handler, or isn't this at all the way Character Palette (et al) implement this. Hopefully I'm on the right track and I just have an embarrassing little coding error? Please advise.

Thanks,
Brad

----begin-code-snippet----
int xyzzyEmitString( UniChar* o, int len, int modifiers, int modStyle ){
EventRef e;
OSStatus stat;


stat = CreateEvent( NULL, kEventClassTextInput, kEventTextInputUnicodeText, 0, kEventAttributeNone, &e );
if( stat == noErr ){
CFStringRef str;
str = CFStringCreateWithCharacters( NULL, o, len );
if( str == NULL ){
printf( "xyzzyEmitString: no space for string!\n" );
return 0;
}
else{
/* Does this really need byte size or character size? */
stat = SetEventParameter( e, kEventParamTextInputSendText, typeUnicodeText, sizeof( UniChar ) * len, str );
if( stat == noErr ){
stat = SendTextInputEvent( e );
// don't want stat == -9874 (eventNotHandledErr) !!!
// but that's what's coming back... :( is the parameter just wrong, or need a listener, or ???
}
}
}
return len;
}

----end-code-snippet----


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >SendTextInputEvent returns eventNoHandledErr (-9874) with kEventTextInputUnicodeText type event (From: Bradford Werner <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.