X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4a5f235122c50b1a5c64960b59bd9d6f90f243c9..23866d595f47f48356cc63890f80049fb0f1dd43:/src/mac/carbon/toplevel.cpp diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 3d08481561..896ede9fdb 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,17 @@ 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 ; + + if ( button == 0 ) + lastButton = 0 ; + 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 @@ -293,29 +306,39 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) break ; } } - // determinate the correct click button - if ( button == kEventMouseButtonSecondary ) + // translate into wx types + switch ( cEvent.GetKind() ) { - if (cEvent.GetKind() == kEventMouseDown ) - wxevent.SetEventType( clickCount > 1 ? wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN ) ; - else if ( cEvent.GetKind() == kEventMouseUp ) - wxevent.SetEventType(wxEVT_RIGHT_UP ) ; - } - else if ( button == kEventMouseButtonTertiary ) - { - if (cEvent.GetKind() == kEventMouseDown ) - wxevent.SetEventType(clickCount > 1 ? wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN ) ; - else if ( cEvent.GetKind() == kEventMouseUp ) - wxevent.SetEventType(wxEVT_MIDDLE_UP ) ; - } - else - { - if (cEvent.GetKind() == kEventMouseDown ) - wxevent.SetEventType(clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ; - else if ( cEvent.GetKind() == kEventMouseUp ) - wxevent.SetEventType(wxEVT_LEFT_UP ) ; - else if ( cEvent.GetKind() == kEventMouseWheelMoved ) - { + case kEventMouseDown : + switch( button ) + { + case kEventMouseButtonPrimary : + wxevent.SetEventType(clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ; + break ; + case kEventMouseButtonSecondary : + wxevent.SetEventType( clickCount > 1 ? wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN ) ; + break ; + case kEventMouseButtonTertiary : + wxevent.SetEventType(clickCount > 1 ? wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN ) ; + break ; + } + break ; + case kEventMouseUp : + switch( button ) + { + case kEventMouseButtonPrimary : + wxevent.SetEventType( wxEVT_LEFT_UP ) ; + break ; + case kEventMouseButtonSecondary : + wxevent.SetEventType( wxEVT_RIGHT_UP ) ; + break ; + case kEventMouseButtonTertiary : + wxevent.SetEventType( wxEVT_MIDDLE_UP ) ; + break ; + } + break ; + case kEventMouseWheelMoved : + { wxevent.SetEventType(wxEVT_MOUSEWHEEL ) ; // EventMouseWheelAxis axis = cEvent.GetParameter(kEventParamMouseWheelAxis, typeMouseWheelAxis) ; @@ -324,10 +347,12 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) wxevent.m_wheelRotation = delta; wxevent.m_wheelDelta = 1; wxevent.m_linesPerAction = 1; - } - else + break ; + } + default : wxevent.SetEventType(wxEVT_MOTION ) ; - } + break ; + } } ControlRef wxMacFindSubControl( Point location , ControlRef superControl , ControlPartCode *outPart ) @@ -629,7 +654,7 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ; 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 ; @@ -977,12 +1002,17 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of // the content view, so we have to retrieve it explicitely HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID , - *m_peer ) ; + m_peer->GetControlRefAddr() ) ; + if ( !m_peer->Ok() ) + { + // compatibility mode fallback + GetRootControl( (WindowRef) m_macWindow , m_peer->GetControlRefAddr() ) ; + } #else - ::CreateRootControl( (WindowRef)m_macWindow , *m_peer ) ; + ::CreateRootControl( (WindowRef)m_macWindow , m_peer->GetControlRefAddr() ) ; #endif // the root control level handleer - MacInstallEventHandler() ; + MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ) ; // the frame window event handler InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;