#14159: wxMenuItem needs field for client data

47 views
Skip to first unread message

wxTrac

unread,
Mar 30, 2012, 10:27:21 AM3/30/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14159>

#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>

wxTrac

unread,
Mar 30, 2012, 11:33:08 AM3/30/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14159#comment:1>

#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>

wxTrac

unread,
Apr 24, 2014, 11:08:15 AM4/24/14
to wx-...@googlegroups.com
#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
Resolution: | Keywords: wxMenuItem medium
Blocked By: | Blocking:
Patch: 0 |
--------------------------+-------------------------------
Changes (by schpidah):

* cc: schpidah@… (added)


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14159#comment:2>

zura.khe...@gmail.com

unread,
Aug 28, 2014, 7:45:43 AM8/28/14
to wx-...@googlegroups.com
Any updates (in plans) regarding implementing this feature?

Also, it will be fair to mention that wxComboBox has an overload of SetClientObject which supports associating client data (wxClientData) for particular items:

SetClientObject(unsigned int n, wxClientData* clientData)

Vadim Zeitlin

unread,
Aug 28, 2014, 8:35:48 AM8/28/14
to wx-...@googlegroups.com
On Thu, 28 Aug 2014 04:45:43 -0700 (PDT) wrote:

> Any updates (in plans) regarding implementing this feature?

No, sorry. In general, when I say that something "could be useful", it
means that patches implementing this would be accepted, but not at all that
I plan on working on it.

Regards,
VZ

Zura Khetsuriani

unread,
Aug 28, 2014, 8:58:03 AM8/28/14
to wx-...@googlegroups.com
Sounds good. Just in case if someone (including myself :) ) decides to
come up with a patch - it seems it is enough to add "public
wxClientDataContainer" mixin to the list of inherited classes by wxMenuItem.

At least it is how I implement my wxMenuItem derived class.

Thanks,
Zura

wxTrac

unread,
May 15, 2017, 5:05:16 PM5/15/17
to wx-...@googlegroups.com
#14159: Allow associating client data with menu items
--------------------------+-------------------------------
Reporter: Peri | Owner:
Type: enhancement | Status: closed
Priority: low | Milestone:
Component: GUI-all | Version: 2.9.3
Resolution: wontfix | Keywords: wxMenuItem medium
Blocked By: | Blocking:
Patch: 0 |
--------------------------+-------------------------------
Changes (by vadz):

* status: confirmed => closed
* resolution: => wontfix


Comment:

I don't think this is going to ever be done, so let's just close it. See
also #16957 which is a duplicate.

--
Ticket URL: <http://trac.wxwidgets.org/ticket/14159#comment:3>
Reply all
Reply to author
Forward
0 new messages