X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e10e94693f6c763025455c996db542cce86b1e2f..3d63970769b32a93061989a38a00a5b6110bc7a5:/src/mac/carbon/toplevel.cpp diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 89ef280b1a..d4f3e31c97 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "toplevel.h" #endif @@ -159,8 +159,9 @@ static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , Even static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; - - wxWindow* focus = wxWindow::FindFocus() ; + // call DoFindFocus instead of FindFocus, because for Composite Windows(like WxGenericListCtrl) + // FindFocus does not return the actual focus window,but the enclosing window + wxWindow* focus = wxWindow::DoFindFocus(); if ( focus == NULL ) return result ; @@ -211,8 +212,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event event.m_x = point.h; event.m_y = point.v; - event.m_timeStamp = when; - wxWindow* focus = wxWindow::FindFocus() ; + event.SetTimestamp(when); event.SetEventObject(focus); if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey ) @@ -505,8 +505,9 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev } // if ( windowPart == inMenuBar ) else if ( currentMouseWindow ) { - currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ; wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent(); + + currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ; wxevent.SetEventObject( currentMouseWindow ) ; @@ -519,7 +520,13 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev wxToolTip::RelayEvent( currentMouseWindow , wxevent); #endif // wxUSE_TOOLTIPS if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) ) + { + if ((currentMouseWindowParent != NULL) && + (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) + currentMouseWindow = NULL; + result = noErr; + } else { // if the user code did _not_ handle the event, then perform the @@ -549,11 +556,8 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation , modifiers , (ControlActionUPP ) -1 ) ; - // We need to handle the rare case that the control to - // which the currentMouseWindow points gets deleted as - // a reaction to HandleControlClick. This would lead to - // a crash in the update cursor code below. - if (!currentMouseWindowParent->GetChildren().Find( currentMouseWindow )) + if ((currentMouseWindowParent != NULL) && + (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) currentMouseWindow = NULL; } result = noErr ;