|
|
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   |
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();
}
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 17:47:31 CEST 2025
Total time taken to generate the page: 0.00802 seconds
|
|
|