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 » Layout Designer and Menus
Layout Designer and Menus [message #60599] Wed, 29 May 2024 19:03 Go to next message
xbones is currently offline  xbones
Messages: 2
Registered: May 2024
Junior Member
I created a window containing a few text boxes and a button with the Layout Designer. I added an event handler to the button and it works fine.

How can I add a menu, e. g. File -> Exit?

The menu-related tutorials don't use layouts and therefore don't work.
Re: Layout Designer and Menus [message #60602 is a reply to message #60599] Fri, 31 May 2024 08:27 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3432
Registered: August 2008
Senior Veteran
Hi Xbones

MenuBar is not included in the layout designer. You can simply include it and fill it with options.

You have an example here:
https://www.ultimatepp.org/srcdoc$CtrlLib$Tutorial$en-us.htm l

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyAppWindow : TopWindow {
   MenuBar menu;

   void Exit() {
       if(PromptOKCancel("Exit MyApp?"))
           Break();
   }
   void SubMenu(Bar& bar) {
       bar.Add("Exit", [=] { Exit(); });
   }
   void MainMenu(Bar& bar) {
       bar.Sub("Menu", [=](Bar& bar) { SubMenu(bar); });
   }
   MyAppWindow() {
       Title("My application with menu").Sizeable();
       AddFrame(menu);
       menu.Set([=](Bar& bar) { MainMenu(bar); });
   }
};

GUI_APP_MAIN
{
   MyAppWindow app;
   app.Run();
}


Best regards
IƱaki
Re: Layout Designer and Menus [message #60632 is a reply to message #60602] Fri, 14 June 2024 17:51 Go to previous message
xbones is currently offline  xbones
Messages: 2
Registered: May 2024
Junior Member
Thank you very much!

I had to increase the window's height to add the menu.

If one uses the Layout Designer, the members go into the class declaration (menu and the handler functions) and the constructor in the main file just has a different name.

It works Smile
Previous Topic: U++ and Python
Next Topic: dark RichEdit
Goto Forum:
  


Current Time: Sat Apr 26 02:22:19 CEST 2025

Total time taken to generate the page: 0.00877 seconds