From 2fca5a00045426b4e59c14a575b2baa3628e3847 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 15 Aug 2002 13:28:48 +0000 Subject: [PATCH] (hopefully) workaround for a carbon bug not always setting the modifiers event record field. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16518 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/app.cpp | 25 +++++++++++-------------- src/mac/carbon/app.cpp | 25 +++++++++++-------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 8da87ab337..1fe4f67e18 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -1377,6 +1377,17 @@ void wxApp::MacDoOneEvent() void wxApp::MacHandleModifierEvents( WXEVENTREF evr ) { EventRecord* ev = (EventRecord*) evr ; +#if TARGET_CARBON + if ( ev->what == mouseDown || ev->what == mouseUp || ev->what == activateEvt || + ev->what == keyDown || ev->what == autoKey || ev->what == keyUp || ev->what == nullEvent ) + { + // in these cases the modifiers are already correctly setup by carbon + } + else + { + ev->modifiers = GetCurrentKeyModifiers() ; + } +#endif if ( ev->modifiers != s_lastModifiers && wxWindow::FindFocus() != NULL ) { wxKeyEvent event(wxEVT_KEY_DOWN); @@ -2142,20 +2153,6 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr ) break ; default: { - // if ( s_lastMouseDown == 0 ) - // ev->modifiers |= btnState ; - - // Calling GetNextEvent with a zero event mask will always - // pass back a null event. However, it fills the EventRecord - // with the state of the modifier keys. This is needed since - // the modifier state returned by WaitForNextEvent often is - // wrong mouse move events. The attempt above to correct this - // didn't always work (under OS X at least). - - EventRecord tmp; - ::GetNextEvent(0, &tmp); - ev->modifiers = tmp.modifiers; - wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( win ) win->MacMouseMoved( ev , windowPart ) ; diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 8da87ab337..1fe4f67e18 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -1377,6 +1377,17 @@ void wxApp::MacDoOneEvent() void wxApp::MacHandleModifierEvents( WXEVENTREF evr ) { EventRecord* ev = (EventRecord*) evr ; +#if TARGET_CARBON + if ( ev->what == mouseDown || ev->what == mouseUp || ev->what == activateEvt || + ev->what == keyDown || ev->what == autoKey || ev->what == keyUp || ev->what == nullEvent ) + { + // in these cases the modifiers are already correctly setup by carbon + } + else + { + ev->modifiers = GetCurrentKeyModifiers() ; + } +#endif if ( ev->modifiers != s_lastModifiers && wxWindow::FindFocus() != NULL ) { wxKeyEvent event(wxEVT_KEY_DOWN); @@ -2142,20 +2153,6 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr ) break ; default: { - // if ( s_lastMouseDown == 0 ) - // ev->modifiers |= btnState ; - - // Calling GetNextEvent with a zero event mask will always - // pass back a null event. However, it fills the EventRecord - // with the state of the modifier keys. This is needed since - // the modifier state returned by WaitForNextEvent often is - // wrong mouse move events. The attempt above to correct this - // didn't always work (under OS X at least). - - EventRecord tmp; - ::GetNextEvent(0, &tmp); - ev->modifiers = tmp.modifiers; - wxTopLevelWindowMac* win = wxFindWinFromMacWindow( window ) ; if ( win ) win->MacMouseMoved( ev , windowPart ) ; -- 2.45.2