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 » Community » Newbie corner » Sub menu in a toolbar?
Sub menu in a toolbar? [message #60485] Wed, 06 March 2024 11:02 Go to next message
Mountacir is currently offline  Mountacir
Messages: 49
Registered: November 2021
Member
Hi,

Is there a way to add submenus to a toolbar?
Something like or close to this:
index.php?t=getfile&id=6911&private=0

I thought of using a DropList but i also need nested submenus.

Thanks!
  • Attachment: toolbar.png
    (Size: 17.32KB, Downloaded 146 times)
Re: Sub menu in a toolbar? [message #60488 is a reply to message #60485] Thu, 07 March 2024 20:54 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1094
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



[Updated on: Thu, 07 March 2024 20:57]

Report message to a moderator

Re: Sub menu in a toolbar? [message #60507 is a reply to message #60485] Thu, 14 March 2024 01:22 Go to previous message
Mountacir is currently offline  Mountacir
Messages: 49
Registered: November 2021
Member
Hi Oblivion,


This is very very helpful, even better/simpler than the ctrl i started making.

Thank you very much Oblivion!
Previous Topic: Link an object file
Next Topic: An error occurred while building capturescreenDll in debug mode
Goto Forum:
  


Current Time: Mon Jun 17 09:13:58 CEST 2024

Total time taken to generate the page: 0.01624 seconds