I’m trying to help track this down… I’ve discovered that while most events are getting dispatched OK, menu events are not.
Find below the example app I’m using to test. It’s a simple variation of Bruce’s example with a switch to use the Interact loop or the MainLoop() method.
If I use the MainLoop and click on a menu item, control eventually trickles down to menuNeedsUpdate:
#2 0x00000001016995c8 in wxMenu::HandleMenuOpened (this=0x103686600) at menu_osx.cpp:468
#3 0x00000001017b4f72 in -[wxNSMenuController menuNeedsUpdate:] (self=0x103682d00, _cmd=0x7fff958d1dc0, smenu=0x103685ba0) at menu.mm:93
#4 0x00007fff950d9c09 in -[NSMenu _populateFromDelegateWithEventRef:] ()
#5 0x00007fff94fce38c in -[NSMenu _populateWithEventRef:] ()
#6 0x00007fff950d8e33 in -[NSCarbonMenuImpl _carbonPopulateEvent:handlerCallRef:] ()
#7 0x00007fff950d89bb in NSSLMMenuEventHandler ()
#8 0x00007fff9381c234 in DispatchEventToHandlers ()
#9 0x00007fff9381b840 in SendEventToEventTargetInternal ()
#10 0x00007fff9381b67a in SendEventToEventTargetWithOptions ()
#11 0x00007fff9384dd29 in SendMenuPopulate ()
#12 0x00007fff9399a195 in SendMenuOpening ()
#13 0x00007fff9399d6d9 in DrawTheMenu ()
#14 0x00007fff9399dbe3 in MenuChanged ()
#15 0x00007fff9386da2f in TrackMenuCommon ()
#16 0x00007fff93868f13 in MenuSelectCore ()
#17 0x00007fff93868592 in _HandleMenuSelection2 ()
#18 0x00007fff94fd91da in _NSHandleCarbonMenuEvent ()
#19 0x00007fff94f6ecc9 in _DPSNextEvent ()
#20 0x00007fff94f6e07d in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#21 0x00007fff94f6a9b9 in -[NSApplication run] ()
#22 0x00000001017a84cc in wxGUIEventLoop::DoRun (this=0x1003aa670) at evtloop.mm:246
#23 0x00000001015a4d63 in wxCFEventLoop::Run (this=0x1003aa670) at evtloop_cf.cpp:403
#24 0x00000001013ed889 in wxAppConsoleBase::MainLoop (this=0x1045097a0) at appbase.cpp:314
#25 0x00000001010d5f9f in wxPyApp::MainLoop (this=0x1045097a0) at helpers.cpp:215
#26 0x00000001010ff649 in _wrap_PyApp_MainLoop (unnamed_arg=0x0, args=0x10056d610) at _core_wrap.cpp:34287
#27 0x00000001000c22c2 in PyEval_EvalFrameEx ()
#28 0x00000001000c4149 in PyEval_EvalCodeEx ()
#29 0x000000010003d910 in function_call ()
#30 0x000000010000c362 in PyObject_Call ()
#31 0x000000010001e97b in instancemethod_call ()
#32 0x000000010000c362 in PyObject_Call ()
#33 0x00000001000bf2c8 in PyEval_EvalFrameEx ()
#34 0x00000001000c286d in PyEval_EvalFrameEx ()
#35 0x00000001000c286d in PyEval_EvalFrameEx ()
#36 0x00000001000c4149 in PyEval_EvalCodeEx ()
#37 0x00000001000c4266 in PyEval_EvalCode ()
#38 0x00000001000e8a0c in PyRun_InteractiveOneFlags ()
#39 0x00000001000e8c6e in PyRun_InteractiveLoopFlags ()
#40 0x00000001000e9451 in PyRun_AnyFileExFlags ()
#41 0x000000010010006d in Py_Main ()
#42 0x0000000100000f14 in dyld_stub_strlen ()
Current language: auto; currently c++
(gdb)
On the other hand… if I use the InteractLoop this never gets called. I did check that the NSMenuController is getting created correctly when the menus are initialized in the “create()” function of the python script. As far as non-menu event handling it seems to wind up in the CommonModeObserverCallBack in either case. Here’s the MainLoop version:
#0 wxCFEventLoop::CommonModeObserverCallBack (this=0x104a3dde0, unnamed_arg=0x104a25270, activity=2) at evtloop_cf.cpp:156
#1 0x00000001015a441b in wxCFEventLoop::OSXCommonModeObserverCallBack (observer=0x104a25270, activity=2, info=0x104a3dde0) at evtloop_cf.cpp:144
#2 0x00007fff8f0378e7 in CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION ()
#3 0x00007fff8f037846 in __CFRunLoopDoObservers ()
#4 0x00007fff8f00caf9 in __CFRunLoopRun ()
#5 0x00007fff8f00c486 in CFRunLoopRunSpecific ()
#6 0x00007fff938162bf in RunCurrentEventLoopInMode ()
#7 0x00007fff9381d4bf in ReceiveNextEventCommon ()
#8 0x00007fff9381d3fa in BlockUntilNextEventMatchingListInMode ()
#9 0x00007fff94f6e779 in _DPSNextEvent ()
#10 0x00007fff94f6e07d in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#11 0x00007fff94f6a9b9 in -[NSApplication run] ()
#12 0x00000001017a84cc in wxGUIEventLoop::DoRun (this=0x104a3dde0) at evtloop.mm:246
#13 0x00000001015a4d63 in wxCFEventLoop::Run (this=0x104a3dde0) at evtloop_cf.cpp:403
#14 0x00000001013ed889 in wxAppConsoleBase::MainLoop (this=0x10365d880) at appbase.cpp:314
#15 0x00000001010d5f9f in wxPyApp::MainLoop (this=0x10365d880) at helpers.cpp:215
#16 0x00000001010ff649 in _wrap_PyApp_MainLoop (unnamed_arg=0x0, args=0x10056d610) at _core_wrap.cpp:34287
#17 0x00000001000c22c2 in PyEval_EvalFrameEx ()
#18 0x00000001000c4149 in PyEval_EvalCodeEx ()
#19 0x000000010003d910 in function_call ()
#20 0x000000010000c362 in PyObject_Call ()
#21 0x000000010001e97b in instancemethod_call ()
#22 0x000000010000c362 in PyObject_Call ()
#23 0x00000001000bf2c8 in PyEval_EvalFrameEx ()
#24 0x00000001000c286d in PyEval_EvalFrameEx ()
#25 0x00000001000c286d in PyEval_EvalFrameEx ()
#26 0x00000001000c4149 in PyEval_EvalCodeEx ()
#27 0x00000001000c4266 in PyEval_EvalCode ()
#28 0x00000001000e8a0c in PyRun_InteractiveOneFlags ()
#29 0x00000001000e8c6e in PyRun_InteractiveLoopFlags ()
#30 0x00000001000e9451 in PyRun_AnyFileExFlags ()
#31 0x000000010010006d in Py_Main ()
#32 0x0000000100000f14 in dyld_stub_strlen ()
And here’s the Interact Loop:
#0 wxCFEventLoop::CommonModeObserverCallBack (this=0x104b64160, unnamed_arg=0x104b6cbc0, activity=2) at evtloop_cf.cpp:156
#1 0x00000001015a441b in wxCFEventLoop::OSXCommonModeObserverCallBack (observer=0x104b6cbc0, activity=2, info=0x104b64160) at evtloop_cf.cpp:144
#2 0x00007fff8f0378e7 in CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION ()
#3 0x00007fff8f037846 in __CFRunLoopDoObservers ()
#4 0x00007fff8f00caf9 in __CFRunLoopRun ()
#5 0x00007fff8f00c486 in CFRunLoopRunSpecific ()
#6 0x00007fff938162bf in RunCurrentEventLoopInMode ()
#7 0x00007fff9381d4bf in ReceiveNextEventCommon ()
#8 0x00007fff9381d3fa in BlockUntilNextEventMatchingListInMode ()
#9 0x00007fff94f6e779 in _DPSNextEvent ()
#10 0x00007fff94f6e07d in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#11 0x00000001017a8809 in wxGUIEventLoop::DoDispatchTimeout (this=0x104b64160, timeout=0) at evtloop.mm:232
#12 0x00000001015a4051 in wxCFEventLoop::DispatchTimeout (this=0x104b64160, timeout=0) at evtloop_cf.cpp:314
#13 0x00000001015a3fb1 in wxCFEventLoop::DoProcessEvents (this=0x104b64160) at evtloop_cf.cpp:301
#14 0x00000001015a3fde in wxCFEventLoop::Dispatch (this=0x104b64160) at evtloop_cf.cpp:306
#15 0x00000001010fdafc in _wrap_EventLoopBase_Dispatch (unnamed_arg=0x0, args=0x1005bc850) at _core_wrap.cpp:35858
#16 0x00000001000c22c2 in PyEval_EvalFrameEx ()
#17 0x00000001000c4149 in PyEval_EvalCodeEx ()
#18 0x00000001000c1a3d in PyEval_EvalFrameEx ()
#19 0x00000001000c286d in PyEval_EvalFrameEx ()
#20 0x00000001000c286d in PyEval_EvalFrameEx ()
#21 0x00000001000c4149 in PyEval_EvalCodeEx ()
#22 0x00000001000c4266 in PyEval_EvalCode ()
#23 0x00000001000e8a0c in PyRun_InteractiveOneFlags ()
#24 0x00000001000e8c6e in PyRun_InteractiveLoopFlags ()
#25 0x00000001000e9451 in PyRun_AnyFileExFlags ()
#26 0x000000010010006d in Py_Main ()
#27 0x0000000100000f14 in dyld_stub_strlen ()
Current language: auto; currently c++
Both wind up in _DPSNextEvent(). While it’s handled correctly for “regular” events, either the Menu events are not getting generated, or they are not being handled. Is it possible there are some events being created and/or handled in the MainLoop() version that aren’t in the Interact?
Any insight appreciated!
thanks,
-steve
···
On Tuesday, January 29, 2013 12:59:42 PM UTC-7, Bruce Sherwood wrote:
Oh dear. I’ll keep my fingers crossed. It would be really unfortunate if menus can’t work in VPython on the Mac, especially since they work fine on Windows and Linux.