Hi there
Does anyone know the reason why MenuBar cannot get mouse events?
As the code bellow demonstrates,
import wx
class Frame(wx.Frame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
panel = wx.Panel(self)
menubar = wx.MenuBar()
menu = wx.Menu()
menuexit = menu.Append(wx.ID_EXIT, "Exit\tCtrl-q")
self.Bind(wx.EVT_MENU, print, menuexit)
menubar.Append(menu, "File")
self.SetMenuBar(menubar)
statusbar = wx.StatusBar(self)
self.SetStatusBar(statusbar)
def echo(v):
print(v.EventObject)
self.Bind(wx.EVT_CONTEXT_MENU, echo)
panel.Bind(wx.EVT_CONTEXT_MENU, echo)
menubar.Bind(wx.EVT_CONTEXT_MENU, echo)
statusbar.Bind(wx.EVT_CONTEXT_MENU, echo)
self.Bind(wx.EVT_LEFT_DOWN, echo)
panel.Bind(wx.EVT_LEFT_DOWN, echo)
menubar.Bind(wx.EVT_LEFT_DOWN, echo)
statusbar.Bind(wx.EVT_LEFT_DOWN, echo)
app = wx.App()
frm = Frame(None)
frm.Show()
app.MainLoop()
every wx.Window objects such as the titlebar, statusbar, (maybe toolbar too?) and panel can get mouse events, but why not menubar?