-static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- wxWindow* focus = wxWindow::FindFocus() ;
- char charCode ;
- UInt32 keyCode ;
- UInt32 modifiers ;
- Point point ;
-
- EventRef rawEvent ;
-
- GetEventParameter( event , kEventParamTextInputSendKeyboardEvent ,typeEventRef,NULL,sizeof(rawEvent),NULL,&rawEvent ) ;
-
- GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
- GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
- GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
- GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL,
- sizeof( Point ), NULL, &point );
-
- switch ( GetEventKind( event ) )
- {
- case kEventTextInputUnicodeForKeyEvent :
- // this is only called when no default handler has jumped in, eg a wxControl on a floater window does not
- // get its own kEventTextInputUnicodeForKeyEvent, so we route back the
- wxControl* control = wxDynamicCast( focus , wxControl ) ;
- if ( control )
- {
- ControlRef macControl = (ControlRef) control->GetHandle() ;
- if ( macControl )
- {
- ::HandleControlKey( macControl , keyCode , charCode , modifiers ) ;
- result = noErr ;
- }
- }
- /*
- // this may lead to double events sent to a window in case all handlers have skipped the key down event
- UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
- UInt32 message = (keyCode << 8) + charCode;
-
- if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
- focus , message , modifiers , when , point.h , point.v ) )
- {
- result = noErr ;
- }
- */
- break ;
- }
-
- return result ;
-}
-