+ }
+ else
+ result = CallNextEventHandler(handler, event);
+
+ if ( UMAGetSystemVersion() < 0x1050 )
+ {
+// set back to 0 if problems arise
+#if 1
+ ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode );
+ // synthesize the event focus changed event
+ EventRef evRef = NULL ;
+
+ OSStatus err = MacCreateEvent(
+ NULL , kEventClassControl , kEventControlFocusPartChanged , TicksToEventTime( TickCount() ) ,
+ kEventAttributeUserEvent , &evRef );
+ verify_noerr( err );
+
+ wxMacCarbonEvent iEvent( evRef ) ;
+ iEvent.SetParameter<ControlRef>( kEventParamDirectObject , controlRef ) ;
+ iEvent.SetParameter<ControlPartCode>( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart ) ;
+ iEvent.SetParameter<ControlPartCode>( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart ) ;
+
+#if 0
+ // TODO test this first, avoid double posts etc...
+ PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh );
+#else
+ wxMacWindowControlEventHandler( NULL , evRef , data ) ;
+#endif
+ ReleaseEvent( evRef ) ;
+#else
+ // old implementation, to be removed if the new one works
+ if ( controlPart == kControlFocusNoPart )
+ {
+#if wxUSE_CARET
+ if ( thisWindow->GetCaret() )
+ thisWindow->GetCaret()->OnKillFocus();
+#endif
+
+ wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow));
+
+ static bool inKillFocusEvent = false ;
+
+ if ( !inKillFocusEvent )
+ {
+ inKillFocusEvent = true ;
+ wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
+ event.SetEventObject(thisWindow);
+ thisWindow->HandleWindowEvent(event) ;
+ inKillFocusEvent = false ;
+ }
+ }
+ else
+ {
+ // panel wants to track the window which was the last to have focus in it
+ wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow));
+ wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
+ thisWindow->HandleWindowEvent(eventFocus);
+
+ #if wxUSE_CARET
+ if ( thisWindow->GetCaret() )
+ thisWindow->GetCaret()->OnSetFocus();
+ #endif
+
+ wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
+ event.SetEventObject(thisWindow);
+ thisWindow->HandleWindowEvent(event) ;
+ }
+#endif
+ }