#14159: wxMenuItem needs field for client data
-------------------------+--------------------------------------------------
Reporter: Peri | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: GUI-all | Version: 2.9.3
Keywords: | Blockedby:
Patch: 0 | Blocking:
-------------------------+--------------------------------------------------
When creating menu items, sometimes a menu item needs to refer to some
client data, other than a control id. For example, if you are creating
menu items that refer to rows from a database query, you may want to store
primary keys or pointers to cached query results so that when a user
selects the menu item, it's easy to get the associated data.
Time and time again I end up caching an array of clent data in a higher
level class instance (essentially in a global variable) and, upon menu
item selection, search it for the associated data. This works fine, but is
not something I like to do.
You may have a good reason for not doing this; if so, please post.
--
Ticket URL: <http://trac.wxwidgets.org/ticket/14159>
#14159: Allow associating client data with menu items
-------------------------------+--------------------------------------------
Reporter: Peri | Owner:
Type: enhancement | Status: confirmed
Priority: low | Milestone:
Component: GUI-all | Version: 2.9.3
Keywords: wxMenuItem medium | Blockedby:
Patch: 0 | Blocking:
-------------------------------+--------------------------------------------
Changes (by vadz):
* keywords: => wxMenuItem medium
* priority: normal => low
* status: new => confirmed
Comment:
It's relatively rare to have dynamically constructed menus (if only
because it's a bad idea to have many items in a menu), unlike, say,
dynamically filled list box (which is almost always the case). But, in
principle, yes, I agree, this could be useful. It could be better to allow
adding items of your custom `wxMenuItem`-derived class to the menu instead
of just adding (untyped) client data pointer to the base class itself.
--
Ticket URL: <http://trac.wxwidgets.org/ticket/14159#comment:1>