From: Stefan Csomor Date: Tue, 20 Jul 2004 14:10:11 +0000 (+0000) Subject: trying to support non-wx controls on a window X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d88ffaaa76c8c98f326457fb313bc98690cf64b6?ds=sidebyside trying to support non-wx controls on a window git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28327 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index a649ffa03e..ab1c994ddd 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -424,7 +424,8 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev short windowPart = ::FindWindow(screenMouseLocation, &window); wxWindow* currentMouseWindow = NULL ; - + ControlRef control = NULL ; + if ( window ) { QDGlobalToLocalPoint( UMAGetWindowPort(window ) , &windowMouseLocation ) ; @@ -436,14 +437,15 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev else if ( (IsWindowActive(window) && windowPart == inContent) ) { ControlPartCode part ; - ControlRef control = wxMacFindControlUnderMouse( windowMouseLocation , window , &part ) ; + control = wxMacFindControlUnderMouse( windowMouseLocation , window , &part ) ; + // if there is no control below the mouse position, send the event to the toplevel window itself if ( control == 0 ) currentMouseWindow = (wxWindow*) data ; else currentMouseWindow = wxFindControlFromMacControl( control ) ; } } - + wxMouseEvent wxevent(wxEVT_LEFT_DOWN); SetupMouseEvent( wxevent , cEvent ) ; @@ -549,6 +551,29 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev // update cursor ? } } // else if ( currentMouseWindow ) + else + { + // don't mess with controls we don't know about + // for some reason returning eventNotHandledErr does not lead to the correct behaviour + // so we try sending them the correct control directly + wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; + if ( toplevelWindow && control ) + { + EventModifiers modifiers = cEvent.GetParameter(kEventParamKeyModifiers, typeUInt32) ; + Point clickLocation = windowMouseLocation ; +#if TARGET_API_MAC_OSX + HIPoint hiPoint ; + hiPoint.x = clickLocation.h ; + hiPoint.y = clickLocation.v ; + HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ; + clickLocation.h = (int)hiPoint.x ; + clickLocation.v = (int)hiPoint.y ; +#endif + HandleControlClick( control , clickLocation , + modifiers , (ControlActionUPP ) -1 ) ; + result = noErr ; + } + } return result ; }