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 #25366 is a reply to message #25357] Fri, 19 February 2010 09:35 Go to previous messageGo to previous message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Showing popup dialog certainly closes prevously opened context menu, so it's not exactly what I wanted.
I've modified your example a bit, and your idea using PopUp/Close worked! Thanks a lot!

Still I want to warn everyone: don't show menu with Execute() if you want it to be closed automatically, it doesn't work in any way. Just use PopUp/Close.

Slightly modified Andrei's working example is following
(thank you, Andrei, again!)

#include <CtrlLib/CtrlLib.h>
using namespace Upp;

class MenuTest : public TopWindow {
public:
	typedef MenuTest CLASSNAME;
	MenuTest()
	{
		menuBar.Set(THISBACK(ThisMenu));
		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()
	{
		//...
		//some internal work
		//...
		menuBar.Close(); // <-- try to close menu here
	}
	void RightDown(Point p, dword d)
	{
		if (menuBar.IsOpen()) {
			menuBar.Close();
			menuBar.PopUp();
		} else
			menuBar.PopUp();
	}
	void Action() {}
	EditField ef;
	MenuBar menuBar;
};

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: Sun May 05 10:12:20 CEST 2024

Total time taken to generate the page: 0.02712 seconds