Home » Community » Newbie corner » Sub menu in a toolbar?
|
Re: Sub menu in a toolbar? [message #60488 is a reply to message #60485] |
Thu, 07 March 2024 20:54   |
Oblivion
Messages: 1204 Registered: August 2007
|
Senior Contributor |
|
|
Hello Mountacir,
One way:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct TestApp : TopWindow {
typedef TestApp CLASSNAME;
ToolBar bar;
ToolButton bt1, bt2;
FrameRight<ToolButton> bt3;
TestApp()
{
Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 640, 400);
bt1.Image(CtrlImg::File());
bt2.Image(CtrlImg::Dir());
AddFrame(bar.MaxIconSize(Size(32, 32)));
bar.Set(THISFN(MainBar));
bt1.AddFrame(bt3.Width(8));
bt3.Image(CtrlImg::smalldown());
bt3 << [this] { MenuBar::Execute(THISFN(MenuBar), bt1.GetScreenView().BottomLeft()); };
}
void MainBar(Bar& toolbar)
{
toolbar.Add(bt1, 32);
toolbar.Add(bt2, 32);
}
void MenuBar(Bar& menubar)
{
for(int i = 0; i < 10; i++)
menubar.Add(AsString(i), []{});
}
};
GUI_APP_MAIN
{
TestApp().Run();
}
Of course, this isn't ideal, it's just a simple test code to give you an idea. The "elegant" way would be to write your own ctrl and add it to the toolbar. But the idea is the same. You can directly call a menu, and align its position to the button's.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Thu, 07 March 2024 20:57] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 04:27:59 CEST 2025
Total time taken to generate the page: 0.00963 seconds
|