Forum > LCL

submenu opened event / lazy menu creation

(1/2) > >>

Is there any event when a submenu (in a popupmenu) is opened?

I have a very large menu with multiple levels kind of like a file system, so I do not want to create the entire menu at once. Rather when the user opens one submenu/directory, it should initialize that submenu and then the next one only when the user opens another directory.

On GTK it works with OnClick on the directory menuitem, but it does not seem to work on Windows

No idea where to hook. I tried assign Action to parent MenuItem which works in Qt but not in Wine.


--- Quote from: BeniBela on February 24, 2019, 07:34:55 pm ---On GTK it works with OnClick on the directory menuitem, but it does not seem to work on Windows

--- End quote ---
Also work. It is necessary to show before filling somehow that it contains subitems, for example by adding a separator. And by click do something like this:
--- Code: Pascal  window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.MenuGroupClick(Sender: TObject);var  CountBefore: Integer;begin  CountBefore := MenuGroup.Count;  MenuGroup.Add(NewItem('Test1', 0, False, True, nil, 0, ''));  MenuGroup.Add(NewItem('Test2', 0, False, True, nil, 0, ''));  while CountBefore > 0 do  begin    MenuGroup.Items[0].Free;    Dec(CountBefore);  end;end;

That works in a mainmenu, but I cannot get it work in a popupmenu

Maybe you need to invest in a different way of looking at it, have you thought about using a TtreeView ?

At least with that you can collapse the tree.


[0] Message Index

[#] Next page

Go to full version