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 » beginner's questions about menu&bars [SOLVED]+[EXAMPLES]
Re: question about menu [message #1936 is a reply to message #1934] Tue, 28 March 2006 10:57 Go to previous message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
I think this should help:
#include <CtrlLib/CtrlLib.h>

struct App : public TopWindow {
	bool numbers_enabled;

	void Exit() {Close();}

	void EnableNumbers()     {numbers_enabled = !numbers_enabled;}
	void ShowNumber(int n)   {PromptOK(AsString(n));}
	void TestEdit()          {PromptOK("fromEdit");}  //added  No3 - your func
	//add here more funcs to call from menus,,,

	void SubMenu(Bar& bar) {  //this must be imagined as SubSubMenu in fact...
		for(int i = 0; i < 10; i++)
			bar.Add(AsString(i), THISBACK1(ShowNumber, i));
	}


	void Menu(Bar& bar) { //confusing name should be changed to "File"...
		bar.Add("Enable numbers", THISBACK(EnableNumbers)).Check(numbers_enabled);
		bar.Add(numbers_enabled, "Numbers", THISBACK(SubMenu));
		bar.Add("Exit", THISBACK(Exit)).Key(K_CTRL_E);
	}
	
	//added No2 - your extra menu item and subItems 
	void Edit(Bar& bar) {
		bar.Add("EditMy_1", THISBACK(TestEdit)).Key(K_CTRL_D);
		//add more items here...
	}//up to here

	void MainBar(Bar& bar){  //row of main menu "labels" - what you see without opening menus...
		bar.Add("Menu", THISBACK(Menu));
		bar.Add("Edit", THISBACK(Edit));  //added Step1 - extra menu item on Main & callback
	}

	MenuBar menu;

typedef App CLASSNAME;

	App(){
		numbers_enabled = false;
		AddFrame(menu);
		menu.Set(THISBACK(MainBar));
	}
};


GUI_APP_MAIN
{
	App().Run();
}
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Navigating through menu items help line isn't shown [SOLVED?]
Next Topic: Minor crash with Menu... [FIXED]
Goto Forum:
  


Current Time: Sun Jun 16 12:20:30 CEST 2024

Total time taken to generate the page: 0.02358 seconds