From 6d5653493414c8203639682536d005f6d9a13c43 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 11 Sep 2003 18:18:05 +0000 Subject: [PATCH] mouse events added, menu id 0 safety check git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23523 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/app.cpp | 21 ++++++++++++++++++++- src/mac/carbon/app.cpp | 21 ++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 6c43daf5d8..5671d05795 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -299,6 +299,8 @@ void wxApp::MacNewFile() { kEventClassMouse , kEventMouseDown } , { kEventClassMouse , kEventMouseMoved } , + { kEventClassMouse , kEventMouseUp } , + { kEventClassMouse , kEventMouseDragged } , { 'WXMC' , 'WXMC' } } ; @@ -337,6 +339,8 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) // but have to use ReceiveNextEvent dealing with events manually, therefore we also have // deal with clicks in the menu bar explicitely +pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; + static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; @@ -374,6 +378,13 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef } } break ; + case kEventMouseDragged : + case kEventMouseUp : + { + if ( wxTheApp->s_captureWindow ) + wxMacWindowEventHandler( handler , event , (void*) wxTheApp->s_captureWindow->MacGetTopLevelWindow() ) ; + } + break ; case kEventMouseMoved : { wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; @@ -404,7 +415,15 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR wxMenuItem* item = NULL ; if ( mbar ) + { item = mbar->FindItem( id , &menu ) ; + // it is not 100 % sure that an menu of id 0 is really ours, safety check + if ( id == 0 && menu != NULL && menu->GetHMenu() != command.menu.menuRef ) + { + item = NULL ; + menu = NULL ; + } + } if ( item == NULL || menu == NULL || mbar == NULL ) return result ; @@ -424,7 +443,7 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR break ; case kEventCommandUpdateStatus: // eventually trigger an updateui round - result = noErr ; + result = noErr ; break ; default : break ; diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index 6c43daf5d8..5671d05795 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -299,6 +299,8 @@ void wxApp::MacNewFile() { kEventClassMouse , kEventMouseDown } , { kEventClassMouse , kEventMouseMoved } , + { kEventClassMouse , kEventMouseUp } , + { kEventClassMouse , kEventMouseDragged } , { 'WXMC' , 'WXMC' } } ; @@ -337,6 +339,8 @@ MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) // but have to use ReceiveNextEvent dealing with events manually, therefore we also have // deal with clicks in the menu bar explicitely +pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; + static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; @@ -374,6 +378,13 @@ static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef } } break ; + case kEventMouseDragged : + case kEventMouseUp : + { + if ( wxTheApp->s_captureWindow ) + wxMacWindowEventHandler( handler , event , (void*) wxTheApp->s_captureWindow->MacGetTopLevelWindow() ) ; + } + break ; case kEventMouseMoved : { wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ; @@ -404,7 +415,15 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR wxMenuItem* item = NULL ; if ( mbar ) + { item = mbar->FindItem( id , &menu ) ; + // it is not 100 % sure that an menu of id 0 is really ours, safety check + if ( id == 0 && menu != NULL && menu->GetHMenu() != command.menu.menuRef ) + { + item = NULL ; + menu = NULL ; + } + } if ( item == NULL || menu == NULL || mbar == NULL ) return result ; @@ -424,7 +443,7 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR break ; case kEventCommandUpdateStatus: // eventually trigger an updateui round - result = noErr ; + result = noErr ; break ; default : break ; -- 2.45.2