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
blacksheep
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 »

When I want to disable a menuitem, I use

Code: Select all

menu->Enable(ID,FALSE);
and enable:

Code: Select all

menu->Enable(ID,TRUE);
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 :?
MrRage
Knows some wx things
Knows some wx things
Posts: 35
Joined: Fri Mar 11, 2005 3:43 am

Post by MrRage »

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

void wxMenuItem::SetTextColour(const wxColour& colour) const;
Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor »

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)
{
event.Enable(a_test);
}

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