// { kEventClassControl , kEventControlBoundsChanged } ,
} ;
-wxWindowMac* targetWindow = NULL;
-
static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
OSStatus result = eventNotHandledErr ;
+ static wxWindowMac* targetFocusWindow = NULL;
+ static wxWindowMac* formerFocusWindow = NULL;
wxMacCarbonEvent cEvent( event ) ;
case kEventControlFocusPartChanged :
// the event is emulated by wxmac for systems lower than 10.5
{
+ if ( UMAGetSystemVersion() < 0x1050 )
+ {
+ // as it is synthesized here, we have to manually avoid propagation
+ result = noErr;
+ }
ControlPartCode previousControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPreviousPart , typeControlPartCode );
ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlCurrentPart , typeControlPartCode );
inKillFocusEvent = true ;
wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
event.SetEventObject(thisWindow);
- event.SetWindow(targetWindow);
+ event.SetWindow(targetFocusWindow);
thisWindow->HandleWindowEvent(event) ;
inKillFocusEvent = false ;
+ targetFocusWindow = NULL;
}
}
else if ( previousControlPart == 0 )
wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
event.SetEventObject(thisWindow);
+ event.SetWindow(formerFocusWindow);
thisWindow->HandleWindowEvent(event) ;
+ formerFocusWindow = NULL;
}
}
break;
#endif
ControlPartCode controlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart , typeControlPartCode );
if ( controlPart != kControlFocusNoPart )
- targetWindow = thisWindow;
-
+ {
+ targetFocusWindow = thisWindow;
+ wxLogTrace(_T("Focus"), _T("focus to be set(%p)"), wx_static_cast(void*, thisWindow));
+ }
+ else
+ {
+ formerFocusWindow = thisWindow;
+ wxLogTrace(_T("Focus"), _T("focus to be lost(%p)"), wx_static_cast(void*, thisWindow));
+ }
+
ControlPartCode previousControlPart = 0;
verify_noerr( HIViewGetFocusPart(controlRef, &previousControlPart));
verify_noerr( err );
wxMacCarbonEvent iEvent( evRef ) ;
- iEvent.SetParameter<ControlRef>( kEventParamDirectObject , controlRef ) ;
- iEvent.SetParameter<ControlPartCode>( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart ) ;
- iEvent.SetParameter<ControlPartCode>( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart ) ;
+ iEvent.SetParameter<ControlRef>( kEventParamDirectObject , controlRef );
+ iEvent.SetParameter<EventTargetRef>( kEventParamPostTarget, typeEventTargetRef, GetControlEventTarget( controlRef ) );
+ iEvent.SetParameter<ControlPartCode>( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart );
+ iEvent.SetParameter<ControlPartCode>( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart );
-#if 0
+#if 1
// TODO test this first, avoid double posts etc...
PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh );
#else
// as we cannot rely on the control features to find out whether we are in full keyboard mode,
// we can only leave in case of an error
+ wxLogTrace(_T("Focus"), _T("before wxWindow::SetFocus(%p)"), wx_static_cast(void*, this));
OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ;
if ( err == errCouldntSetFocus )
return ;
+ wxLogTrace(_T("Focus"), _T("after wxWindow::SetFocus(%p)"), wx_static_cast(void*, this));
SetUserFocusWindow( (WindowRef)MacGetTopLevelWindowRef() );
}