Has anyone had any luck binding CMD+Q when using an AcceleratorTable, under OS X? I already have a bunch of shortcut keys that work in both Windows and Mac, but when attempting to bind the CMD key, I just get the (un)helpful honk from the OS.
This little test app will demonstrate the problem:
import wx
def QuitWithCmdQ(event):
print 'quitting!'
event.Skip()
def TestFunction(event):
print 'Received', type(event)
event.Skip()
app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, “Hello World”)
cmd_q = wx.NewId()
cmd_w = wx.NewId()
frame.Bind(wx.EVT_MENU, QuitWithCmdQ, id=cmd_q)
frame.Bind(wx.EVT_MENU, TestFunction, id=cmd_w)
accelerators = wx.AcceleratorTable([
(wx.ACCEL_CMD, ord('Q'), cmd_q),
(wx.ACCEL_NORMAL, ord('W'), cmd_w),
])
frame.SetAcceleratorTable(accelerators)
frame.Show(True)
app.MainLoop()
When pressing ‘W’ it works fine, and should print out “Received <class ‘wx._core.CommandEvent’>”
When pressing ‘CMD+Q’ it doesn’t do anything!
If anyone has an idea where I’m going wrong I would appreciate the insight!