attempt to fix part of the focus problem under 10.5

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@50117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2007-11-20 22:36:29 +00:00
parent e1ac649f62
commit aee427f150

View File

@@ -184,6 +184,7 @@ static const EventTypeSpec eventList[] =
{ kEventClassControl , kEventControlActivate } , { kEventClassControl , kEventControlActivate } ,
{ kEventClassControl , kEventControlDeactivate } , { kEventClassControl , kEventControlDeactivate } ,
#endif #endif
{ kEventClassControl , kEventControlGetFocusPart } ,
{ kEventClassControl , kEventControlSetFocusPart } , { kEventClassControl , kEventControlSetFocusPart } ,
{ kEventClassService , kEventServiceGetTypes }, { kEventClassService , kEventServiceGetTypes },
@@ -326,6 +327,14 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
#endif // TARGET_API_MAC_OSX #endif // TARGET_API_MAC_OSX
// we emulate this event under Carbon CFM // we emulate this event under Carbon CFM
case kEventControlGetFocusPart :
if ( thisWindow->MacIsUserPane() )
{
// kHIViewEntireView and kHIViewNoPart have the same code, needed for Leopard
cEvent.SetParameter<ControlPartCode>(kEventParamControlPart , kHIViewEntireView );
result = noErr ;
}
break ;
case kEventControlSetFocusPart : case kEventControlSetFocusPart :
{ {
Boolean focusEverything = false ; Boolean focusEverything = false ;
@@ -339,7 +348,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
if ( thisWindow->MacIsUserPane() ) if ( thisWindow->MacIsUserPane() )
result = noErr ; result = noErr ;
if ( controlPart == kControlFocusNoPart ) if ( controlPart == kControlFocusNoPart )
{ {
#if wxUSE_CARET #if wxUSE_CARET
@@ -347,6 +356,8 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
thisWindow->GetCaret()->OnKillFocus(); thisWindow->GetCaret()->OnKillFocus();
#endif #endif
wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow));
static bool inKillFocusEvent = false ; static bool inKillFocusEvent = false ;
if ( !inKillFocusEvent ) if ( !inKillFocusEvent )
@@ -361,6 +372,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
else else
{ {
// panel wants to track the window which was the last to have focus in it // 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); wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
thisWindow->GetEventHandler()->ProcessEvent(eventFocus); thisWindow->GetEventHandler()->ProcessEvent(eventFocus);
@@ -1269,11 +1281,15 @@ void wxWindowMac::SetFocus()
// as we cannot rely on the control features to find out whether we are in full keyboard mode, // 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 // we can only leave in case of an error
wxLogTrace(_T("Focus"), _T("SetFocus(%p)"), wx_static_cast(void*, this));
OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ; OSStatus err = m_peer->SetFocus( kControlFocusNextPart ) ;
if ( err == errCouldntSetFocus ) if ( err == errCouldntSetFocus )
return ; return ;
SetUserFocusWindow( (WindowRef)MacGetTopLevelWindowRef() ); if ( GetUserFocusWindow() != (WindowRef)MacGetTopLevelWindowRef() )
SetUserFocusWindow( (WindowRef)MacGetTopLevelWindowRef() );
#if !TARGET_API_MAC_OSX #if !TARGET_API_MAC_OSX
// emulate carbon events when running under CarbonLib where they are not natively available // emulate carbon events when running under CarbonLib where they are not natively available
@@ -2731,6 +2747,9 @@ wxWindow *wxWindowBase::DoFindFocus()
{ {
ControlRef control ; ControlRef control ;
GetKeyboardFocus( GetUserFocusWindow() , &control ) ; GetKeyboardFocus( GetUserFocusWindow() , &control ) ;
wxLogTrace(_T("Focus"), _T("FindFocus(windowref=%p, peer =%p, wxwindow = %p)"),
wx_static_cast(void*, GetUserFocusWindow()), wx_static_cast(void*, control)
, wx_static_cast(void*, wxFindControlFromMacControl( control )));
return (wxWindow*)wxFindControlFromMacControl( control ) ; return (wxWindow*)wxFindControlFromMacControl( control ) ;
} }