开发者

Binding event to wxMenu instead of wxMenuItem

开发者 https://www.devze.com 2022-12-19 05:41 出处:网络
开发者_如何学PythonIm creating a dynamic MenuBar from xml file, and binding events to menu items using Connect().
开发者_如何学Python

Im creating a dynamic MenuBar from xml file, and binding events to menu items using Connect().

Some menus does not have items inside, but needs to fire events.

Is there a way to attach an event handler to a wxMenu using Connect()?

*Im Using wxWidgets 2.8.8 & MS VC++ 6.0


Ive tried many things, but nothing worked out for me.
As a quick answaer ill quote Vadim Zeitlin from wx-widgets list:

No, you shouldn't associate commands directly to top level menus. This is discouraged under all systems and is not supported at all under some of them.


I think you can trap EVT_MENU_OPEN (see wxMenuEvent).

Connecting it might look like this:

Connect(wxEVT_MENU_OPEN, wxMenuEventHandler(MyFrame::OnMenuOpen), 0, 0);
0

精彩评论

暂无评论...
验证码 换一张
取 消