X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/827e7a487462cb19677fcc50f3d3eb047651e95e..613b6bb90a2345b7160dca1a72685c1ad19f3457:/src/mac/app.cpp diff --git a/src/mac/app.cpp b/src/mac/app.cpp index 98505dac77..9b891f5fa4 100644 --- a/src/mac/app.cpp +++ b/src/mac/app.cpp @@ -104,10 +104,9 @@ long wxApp::sm_lastMessageTime = 0; long wxApp::s_lastModifiers = 0 ; -bool wxApp::s_macDefaultEncodingIsPC = true ; bool wxApp::s_macSupportPCMenuShortcuts = true ; long wxApp::s_macAboutMenuItemId = wxID_ABOUT ; -long wxApp::s_macPreferencesMenuItemId = 0 ; +long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ; long wxApp::s_macExitMenuItemId = wxID_EXIT ; wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ; @@ -299,6 +298,8 @@ void wxApp::MacNewFile() { kEventClassMouse , kEventMouseDown } , { kEventClassMouse , kEventMouseMoved } , + { kEventClassMouse , kEventMouseUp } , + { kEventClassMouse , kEventMouseDragged } , { 'WXMC' , 'WXMC' } } ; @@ -337,6 +338,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 +377,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 +414,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 +442,7 @@ static pascal OSStatus CommandEventHandler( EventHandlerCallRef handler , EventR break ; case kEventCommandUpdateStatus: // eventually trigger an updateui round - result = noErr ; + result = noErr ; break ; default : break ; @@ -570,7 +588,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) #ifndef __DARWIN__ # if __option(profile) - ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ; + ProfilerInit( collectDetailed, bestTimeBase , 40000 , 50 ) ; # endif #endif @@ -990,7 +1008,9 @@ wxApp::wxApp() m_auto3D = TRUE; m_macCurrentEvent = NULL ; +#if TARGET_CARBON m_macCurrentEventHandlerCallRef = NULL ; +#endif } bool wxApp::Initialized() @@ -1377,7 +1397,7 @@ void wxApp::MacHandleModifierEvents( WXEVENTREF evr ) event.SetEventType( ( ev->modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; focus->GetEventHandler()->ProcessEvent( event ) ; } - if ( ev->modifiers ^ s_lastModifiers ) & cmdKey ) + if ( ( ev->modifiers ^ s_lastModifiers ) & cmdKey ) { event.m_keyCode = WXK_COMMAND ; event.SetEventType( ( ev->modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; @@ -1542,7 +1562,7 @@ void wxApp::MacHandleMouseDownEvent( WXEVENTREF evr ) { // Activate window first ::SelectWindow( window ) ; - + // Send event later if ( win ) win->MacMouseDown( ev , windowPart ) ; @@ -2158,7 +2178,7 @@ void wxApp::MacHandleMouseMovedEvent(wxInt32 x , wxInt32 y ,wxUint32 modifiers , event.m_controlDown = modifiers & controlKey; event.m_altDown = modifiers & optionKey; event.m_metaDown = modifiers & cmdKey; - + event.m_x = x; event.m_y = y; event.m_timeStamp = timestamp;