Recent

Author Topic: Any idea for xplat tpopupmenu replacement that not closes when checking items  (Read 569 times)

MISV

  • Hero Member
  • *****
  • Posts: 701
Has anyone in LCL/lazarus community developed a replacement tpopupmenu that does not close when checking items? (e.g. if you have a ton of options shown in a menu)

I guess the common solution is making a window form that reads the menu and generates a tree structure or similar... So that is on my todo list if there isn't already a better solution available

jamie

  • Hero Member
  • *****
  • Posts: 3542
Use a tool Window..
that more or less floats on top.

I guess in Lazarus its a StayOnTop window.
The only true wisdom is knowing you know nothing

lucamar

  • Hero Member
  • *****
  • Posts: 3030
 AFAIK there's no popup-menu substitute that can do that.

What I do for those cases is either show an "Options" form or a panel where the user can select the options, like in the attached image (a generic base program for tests)
« Last Edit: August 20, 2019, 11:41:48 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

winni

  • Hero Member
  • *****
  • Posts: 1817
Yes - ToolWindow with StayOnTop. I did that many times. And dont forget the "close"  option ......

Winni

MISV

  • Hero Member
  • *****
  • Posts: 701
I am thinking about making a custom form that can read a popupmenu.

I have a popupmenu consisting of multiple levels and about 70 menuitem checkbox (for controlling which data columns are visible)

I would almost have though some had made tpoupmenu replacement (form) that could at runtime create checkboxes and other controls + call events etc. so one could reuse TPopupMenu.

Does anyone know of any such? Otherwise I will try roll my own ... Maybe a form with a treeview showing all the nested options

jamie

  • Hero Member
  • *****
  • Posts: 3542
There are a lot of ways of doing what you want that already exists

TtreeView, especially in custom draw mode can do that... etc

TCheckBoxList can also be wedged in there as a popup item in the list and so on..

its a matter of how created you want to be but its all there without creating special controls that will use existing installed components..

 Use a TFRAME to build such an item if you wish. That is the next best thing of creating a special control but without installing it.
The only true wisdom is knowing you know nothing

lucamar

  • Hero Member
  • *****
  • Posts: 3030
Another possible way of doing it might be implementing a helper for TCheckGroup with a method called, say, BuildFromMenu. Building the check group would just be a question of adding an item for each of the menu(item) Items[].

We do something similar to build dynamic check groups from arrays of (string, boolean) pairs and it works quite nicely :)
« Last Edit: February 15, 2020, 09:46:56 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018