Discussion:
EVT_MENU's Event Object is a Menu (not a menu item)
(too old to reply)
Alec Teal
2014-10-01 23:13:13 UTC
Permalink
A while a go I asked about creating a menu "dynamically" (members grow
based on some set at runtime, and I need to know which was clicked)

I got no useful answer (other than the obvious/tedious/bad "dole out
some IDs and hope!") - I have noticed before that wxMenuItem has a
virtual destructor, I've subclassed this but the item returned by the
event is the menu the item is in.

I think this is intended (although I'd love to know where it is
documented) - why is it intended? If a menu item is clicked I expect
which one to be the event object, if I want the menu I'd get it out of
the menu item.

This is a real pain, I can't be the first to want to do this surely!?

Alec
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-10-02 14:27:38 UTC
Permalink
On Thu, 2 Oct 2014 00:13:13 +0100 Alec Teal wrote:

AT> I got no useful answer (other than the obvious/tedious/bad "dole out
AT> some IDs and hope!")

You don't have to dole out anything, just fix the start and end of the
range.

AT> I have noticed before that wxMenuItem has a virtual destructor, I've
AT> subclassed this but the item returned by the event is the menu the item
AT> is in.

I don't understand the relationship to the virtual dtor, but the event
object for the menu events is indeed the menu and not the item.

AT> I think this is intended (although I'd love to know where it is
AT> documented) - why is it intended?

The simplest answer is historical: menu events predate the addition of
wxMenuItem class by quite a few years.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Loading...