// statics for implementation
static bool s_inYield = FALSE;
-static bool s_inOnIdle = FALSE;
#if TARGET_CARBON
static bool s_inReceiveEvent = FALSE ;
{ kEventClassCommand, kEventProcessCommand } ,
{ kEventClassCommand, kEventCommandUpdateStatus } ,
+ { kEventClassMenu, kEventMenuOpening },
+ { kEventClassMenu, kEventMenuClosed },
+
{ kEventClassApplication , kEventAppActivated } ,
{ kEventClassApplication , kEventAppDeactivated } ,
// handling the quit event is not recommended by apple
{ 'WXMC' , 'WXMC' }
} ;
-static pascal OSStatus MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+static pascal OSStatus
+MenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
- return eventNotHandledErr ;
+ // FIXME: this doesn't work for multiple windows
+ wxWindow *win = wxTheApp->GetTopWindow();
+ if ( win )
+ {
+ // VZ: we could find the menu from its handle here by examining all
+ // the menus in the menu bar recursively but knowing that neither
+ // wxMSW nor wxGTK do it why bother...
+#if 0
+ MenuRef menuRef;
+
+ GetEventParameter(event,
+ kEventParamDirectObject,
+ typeMenuRef, NULL,
+ sizeof(menuRef), NULL,
+ &menuRef);
+#endif // 0
+
+ wxMenuEvent wxevent(GetEventKind(event) == kEventMenuOpening
+ ? wxEVT_MENU_OPEN
+ : wxEVT_MENU_CLOSE);
+ wxevent.SetEventObject(win);
+
+ (void)win->GetEventHandler()->ProcessEvent(wxevent);
+ }
+
+ return eventNotHandledErr;
}
// due to the rather low-level event API of wxWindows, we cannot use RunApplicationEventLoop
wxApp::wxApp()
{
- m_topWindow = NULL;
- wxTheApp = this;
-
- argc = 0;
- argv = NULL;
-
m_printMode = wxPRINT_WINDOWS;
m_auto3D = TRUE;
+
+ m_macCurrentEvent = NULL ;
+ m_macCurrentEventHandlerCallRef = NULL ;
}
bool wxApp::Initialized()
return 0;
}
-// Returns TRUE if more time is needed.
-bool wxApp::ProcessIdle()
-{
- wxIdleEvent event;
- event.SetEventObject(this);
- ProcessEvent(event);
-
- return event.MoreRequested();
-}
-
void wxApp::ExitMainLoop()
{
m_keepGoing = FALSE;
#else
EventRecord event ;
- return EventAvail( everyEvent , &event ) ;
+ return EventAvail( everyEvent , &event ) ;
#endif
}
void wxApp::OnIdle(wxIdleEvent& event)
{
- // Avoid recursion (via ProcessEvent default case)
- if ( s_inOnIdle )
- return;
-
-
- s_inOnIdle = TRUE;
-
- // 'Garbage' collection of windows deleted with Close().
- DeletePendingObjects();
-
- // flush the logged messages if any
- wxLog *pLog = wxLog::GetActiveTarget();
- if ( pLog != NULL && pLog->HasPendingMessages() )
- pLog->Flush();
-
- // Send OnIdle events to all windows
- bool needMore = SendIdleEvents();
-
- if (needMore)
- event.RequestMore(TRUE);
-
+ wxAppBase::OnIdle(event);
+
// If they are pending events, we must process them: pending events are
// either events to the threads other than main or events posted with
// wxPostEvent() functions
wxMacProcessNotifierAndPendingEvents();
- s_inOnIdle = FALSE;
if(!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar())
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
}
wxMacWakeUp() ;
}
-// Send idle event to all top-level windows
-bool wxApp::SendIdleEvents()
-{
- bool needMore = FALSE;
- wxWindowListNode* node = wxTopLevelWindows.GetFirst();
- while (node)
- {
- wxWindow* win = node->GetData();
- if (SendIdleEvents(win))
- needMore = TRUE;
-
- node = node->GetNext();
- }
- return needMore;
-}
-
-// Send idle event to window and all subwindows
-bool wxApp::SendIdleEvents(wxWindow* win)
-{
- bool needMore = FALSE;
-
- wxIdleEvent event;
- event.SetEventObject(win);
- win->ProcessEvent(event);
-
- if (event.MoreRequested())
- needMore = TRUE;
-
- wxWindowListNode* node = win->GetChildren().GetFirst();
- while (node)
- {
- wxWindow* win = node->GetData();
- if (SendIdleEvents(win))
- needMore = TRUE;
-
- node = node->GetNext();
- }
- return needMore ;
-}
-
void wxApp::Exit()
{
wxApp::CleanUp();
event.SetEventType( ( ev->modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
focus->GetEventHandler()->ProcessEvent( event ) ;
}
+ if ( ev->modifiers ^ s_lastModifiers ) & cmdKey )
+ {
+ event.m_keyCode = WXK_COMMAND ;
+ event.SetEventType( ( ev->modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
+ focus->GetEventHandler()->ProcessEvent( event ) ;
+ }
s_lastModifiers = ev->modifiers ;
}
}
if ( MacSendKeyDownEvent( focus , ev->message , ev->modifiers , ev->when , ev->where.h , ev->where.v ) == false )
{
+#if 0
+ // we must handle control keys the other way round, otherwise text content is updated too late
// has not been handled -> perform default
wxControl* control = wxDynamicCast( focus , wxControl ) ;
if ( control && control->GetMacControl() != NULL )
keycode = short(ev->message & keyCodeMask) >> 8 ;
::HandleControlKey( (ControlHandle) control->GetMacControl() , keycode , keychar , ev->modifiers ) ;
}
+#endif
}
}
}