Menu items - disable/enable

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
In need of some credit
In need of some credit
Posts: 1
Joined: Sun Mar 20, 2005 1:58 pm

Menu items - disable/enable

Post by blacksheep » Sun Mar 20, 2005 2:11 pm

When I want to disable a menuitem, I use

Code: Select all

and enable:

Code: Select all

The problem: The menuitem is not turning gray... but when I click the menuitem, I know that it is disabled. How can I make a menuitem turn gray when it is disabled?

I've searched the forum, and it seems like I have to use wxUpdateUIEvent, but I have really no idea how to use it :?

Knows some wx things
Knows some wx things
Posts: 35
Joined: Fri Mar 11, 2005 3:43 am

Post by MrRage » Sun Mar 20, 2005 4:23 pm

Just a thought.. but you could set the text color using this, windows only though.

void wxMenuItem::SetTextColour(const wxColour& colour) const;

Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France

Post by Cursor » Sun Mar 20, 2005 8:39 pm

The wxUpdateUIEvent is used like any other event interception : you use the macro to intercept the update event for an specific ID or range of IDs :
EVT_UPDATE_UI(id, func)
EVT_UPDATE_UI_RANGE(id1, id2, func)

you just have to write an interception function :

void MyClass::OnUpdateMenuItem(wxUpdateUIEvent& event)

And the wxUpdateUIEvent class members are usefull to turn on/off a menu (or a toolbar tool, a button ... via the ID) or check it, changing its name ...

Post Reply