Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Menus&Toolbars » Disable/Enable Menu item during runtime
Disable/Enable Menu item during runtime [message #23456] Wed, 21 October 2009 01:58 Go to next message
sdiscool is currently offline  sdiscool
Messages: 2
Registered: October 2008
Junior Member
I know we have a function called Enable. However, I have trouble how to access into it after reading tutorial (i am new to Ultimate ++).

Here is what I have (partial - i use separate CPP/H files):

this->AddFrame(menu);
menu.Set(THISBACK(MainMenu));

void MainMenu(Bar& bar) {
bar.Add("File", THISBACK(SubFileMenu))
.Help("File Menu");
bar.Add("Section", THISBACK(SubSectionMenu))
.Help("Section Menu").Enable(false);
}

void SubFileMenu(Bar& bar) {
bar.Add("Open", THISBACK(File_Open))
.Help("Open Menu");
bar.Add("Close", THISBACK(File_Close))
.Help("Close Menu");
bar.Add("Exit", THISBACK(File_Exit))
.Help("Exit Menu");
}

void File_Open() {
// I want to make "Section" enabled. How can I do it here?
// example: when user opens file, i want section to be enabled.
}

Re: Disable/Enable Menu item during runtime [message #23458 is a reply to message #23456] Wed, 21 October 2009 05:51 Go to previous message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
You need to use method Add, which has a signature below. And you need to recreate menu each time. This is a pretty optimized procedure.

	Item&  Add(bool enable, const char *text, Callback callback);


Your code should look like below.

void MainMenu(Bar& bar) {
   bar.Add("File", THISBACK(SubFileMenu)).Help("File Menu");
   bar.Add(SectionIsEnabled(), "Section", THISBACK(SubSectionMenu)).Help("Section Menu");
}



Regards,
Novo
Previous Topic: ToolBar enabling and disabling question
Next Topic: Bigger images/icons in menu
Goto Forum:
  


Current Time: Fri Mar 29 13:38:24 CET 2024

Total time taken to generate the page: 0.00962 seconds