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 » query , update menu / submenu itens (build routine to query or change menu items at runtime)
Re: query , update menu / submenu itens [message #58350 is a reply to message #58349] Thu, 05 May 2022 20:11 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello BetoValle,

Mirek has alredy pointed to the right direction.

To give you the idea, just try the below rudimentary example.


It appends a simple, programmable popup menu to an array.
To program the menu, simply right click on the array and change its attributes or content...

#include <CtrlLib/Ctr<lLib.h>

using namespace Upp;

struct MenuTest : TopWindow {
	ArrayCtrl list;

	MenuTest()
	{
		SetRect(0, 0, 1024, 768);
		Sizeable().Zoomable().CenterScreen();
		
		// Let's Configure the array.
		Add(list.SizePos());
		list.AddColumn("Text").Edit(Single<EditString>());
		list.AddColumn("State").Ctrls<Option>();
		list.ColumnWidths("200, 20");
		list.Moving().Track().Appending().Removing().SetEditable();
		
		// Fill the array.
		for(int i = 0; i < 10; i++)
			list.Add(AsString(i), (bool) false);
		
		// Override the popup menu of the array
		list.WhenBar = [=](Bar& bar) {
			// RE-add the main popup menu of ArrayCtrl.
			list.StdBar(bar);
			int n = list.GetCount(); // Don't append the user menu to the array menu if the array is empty...
			if(n <= 0)
				return;
			bar.Separator();
			for(int i = 0; i < list.GetCount(); i++) {
				bool   enable = list.Get(i, 1);
				String text   = list.Get(i, 0);
				bar.Add(enable, text, [=]{ PromptOK(text); }); // action!
			}
		};
		
	}

};

GUI_APP_MAIN
{
	MenuTest().Run();
}





Best regards,
Oblivion


[Updated on: Thu, 05 May 2022 20:15]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: menu's small box when i18n
Next Topic: Accelerators stop after popup menu due to focus
Goto Forum:
  


Current Time: Wed May 08 10:08:17 CEST 2024

Total time taken to generate the page: 0.02517 seconds