X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/21fd55291b631eae9ccfd78866616aca6e573ebe..da2101204027855793c4264388b95a208967ae15:/src/mac/carbon/toplevel.cpp diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index e657e1025f..afeecbafc4 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -252,6 +252,8 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event wxWindow* g_MacLastWindow = NULL ; +static EventMouseButton lastButton = 0 ; + static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) { UInt32 modifiers = cEvent.GetParameter(kEventParamKeyModifiers, typeUInt32) ; @@ -275,6 +277,14 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) { button = kEventMouseButtonSecondary ; } + + // we must make sure that our synthetic 'right' button corresponds in + // mouse down, moved and mouse up, and does not deliver a right down and left up + + if ( cEvent.GetKind() == kEventMouseDown ) + lastButton = button ; + else if ( lastButton ) + button = lastButton ; // determinate the correct down state, wx does not want a 'down' for a mouseUp event, while mac delivers // this button @@ -328,6 +338,8 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) else wxevent.SetEventType(wxEVT_MOTION ) ; } + if ( cEvent.GetKind() == kEventMouseUp ) + lastButton = 0 ; } ControlRef wxMacFindSubControl( Point location , ControlRef superControl , ControlPartCode *outPart ) @@ -627,9 +639,9 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand adjustR.SetWidth( toplevelWindow->GetMinWidth() ) ; if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetHeight() < toplevelWindow->GetMinHeight() ) adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ; - Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ; + const Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ; if ( !EqualRect( &newRect , &adjustedRect ) ) - cEvent.SetParameter( kEventParamCurrentBounds , &adjustedRect ) ; + cEvent.SetParameter( kEventParamCurrentBounds , &adjustedRect ) ; } result = noErr ; @@ -978,6 +990,11 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, // the content view, so we have to retrieve it explicitely HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID , *m_peer ) ; + if ( !m_peer->Ok() ) + { + // compatibility mode fallback + GetRootControl( (WindowRef) m_macWindow , *m_peer ) ; + } #else ::CreateRootControl( (WindowRef)m_macWindow , *m_peer ) ; #endif