Home » U++ Library support » Menus&Toolbars » query , update menu / submenu itens (build routine to query or change menu items at runtime)
query , update menu / submenu itens [message #58345] |
Tue, 03 May 2022 19:22  |
BetoValle
Messages: 204 Registered: September 2020 Location: Brasil Valinhos SP
|
Experienced Member |
|
|
Hi,
Based on my constructor routine below**,
How do I create a routine to access each of these menu and sub-menu items to consult the texts of the options (allow changing these texts) and also to enable or disable the option (enable/disable) of each said item?
(how to do in a loop ?
would be something like:
for... dynamic_cast<MenuBar *>(q) ?
how i do ?
)
// ** my constructor!
CtrlLayout ( *this, "Window title" );
//menup is MenuBar created with layoutfile!
menup.Set([=](Bar& bar) {
bar.Sub("Cadastros", [=](Bar& bar) {
bar.Sub("Contas",[=](Bar& bar){
bar.Sub("Disponibilidades",[=](Bar& bar){
bar.Add(false,"Caixa", THISFN(go1));
bar.Add("Bancos", THISFN(go2));
});
bar.Add("Despesas", THISFN(go3));
});
bar.Add("Clientes", THISFN(go4));
});
bar.Add("Sai", THISBACK(Close));
});
note: I didn't find anything similar on the forum!
Thanks!
|
|
|
|
|
|
Re: query , update menu / submenu itens [message #58350 is a reply to message #58349] |
Thu, 05 May 2022 20:11   |
Oblivion
Messages: 1202 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
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, 05 May 2022 20:15] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 12:18:36 CEST 2025
Total time taken to generate the page: 0.00940 seconds
|