Page 1 of 1

Menu items - disable/enable

Posted: Sun Mar 20, 2005 2:11 pm
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 :?

Posted: Sun Mar 20, 2005 4:23 pm
by MrRage
Just a thought.. but you could set the text color using this, windows only though.

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

Posted: Sun Mar 20, 2005 8:39 pm
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 ...