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 » Close context menu from within Execute() handler
Re: Close context menu from within Execute() handler [message #25513 is a reply to message #25421] Fri, 26 February 2010 16:06 Go to previous message
mirek is currently offline  mirek
Messages: 14266
Registered: November 2005
Ultimate Member
It needed a little fix in MenuBar code and it is not quite transparent and usual code, but it works now:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

class MenuTest : public TopWindow {
public:
	MenuBar menu;

	typedef MenuTest CLASSNAME;
	MenuTest()
	{
		ef.WhenEnter = THISBACK(EnterPressed);
	}
	void ThisMenu(Bar& bar)
	{
		bar.Gap(10);
		bar.Add(ef.SizePos(), Size(200, 20));
		bar.Gap(10);
		bar.Add("One", THISBACK(Action));
		bar.Add("Two", THISBACK(Action));
	}
	
	void EnterPressed()
	{
		menu.EndLoop();
	}
	void RightDown(Point p, dword d)
	{
		menu.Set(THISBACK(ThisMenu));
		menu.Execute();
	}
	void Action() {}
	EditField ef;	
};

GUI_APP_MAIN
{
	MenuTest().Run();
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Bigger images/icons in menu
Next Topic: Popup menu on button click
Goto Forum:
  


Current Time: Fri Jul 18 09:54:16 CEST 2025

Total time taken to generate the page: 0.04285 seconds