Recent

Author Topic: [Solved] Adding a named separator  (Read 2435 times)

sarad

  • Newbie
  • Posts: 5
[Solved] Adding a named separator
« on: April 15, 2024, 10:17:34 am »
Hello freaks  ;)

How I can add a named separator (menu group) to a T*Menu?
My desired sytax is - Name -.
« Last Edit: May 03, 2024, 06:34:21 pm by sarad »

VisualLab

  • Hero Member
  • *****
  • Posts: 620
Re: Adding a named separator
« Reply #1 on: April 15, 2024, 10:39:12 am »
Hello freaks  ;)

How I can add a named separator (menu group) to a T*Menu?
My desired sytax is - Name -.

This cannot be done easily in classes (TMainMenu, TPopupMenu) responsible for displaying individual menu items (TMenuItem). You would probably need to refer to WinAPI (Windows) or to the functions contained in the Qt or GTK libraries (Linux). Another solution is to create your own class that displays the menu.

There is one more issue. I suspect that these separators are intended to play two roles:
  • real separator,
  • a description for the set of commands included below this spearator.

If this is the case, I advise against this solution. This is an example of bad GUI design. A multi-level menu is provided for this purpose, i.e. a higher-level menu item groups and describes lower-level items. Users are well familiar with this solution. However, various "fancy" or "contrived" menu options will irritate users. Unless it's a program for your own needs, then it's OK.

Thaddy

  • Hero Member
  • *****
  • Posts: 16422
  • Censorship about opinions does not belong here.
Re: Adding a named separator
« Reply #2 on: April 15, 2024, 10:46:27 am »
I am ot quite sure, but if a name is required, simply use a macro.
Code: Pascal  [Select][+][-]
  1. {$macro on }{$define name :=-}
There is nothing wrong with being blunt. At a minimum it is also honest.

sarad

  • Newbie
  • Posts: 5
Re: Adding a named separator
« Reply #3 on: April 15, 2024, 12:40:34 pm »
There is one more issue. I suspect that these separators are intended to play two roles:
  • real separator,
  • a description for the set of commands included below this spearator.

If this is the case, I advise against this solution. This is an example of bad GUI design. A multi-level menu is provided for this purpose, i.e. a higher-level menu item groups and describes lower-level items. Users are well familiar with this solution. However, various "fancy" or "contrived" menu options will irritate users. Unless it's a program for your own needs, then it's OK.

Thank you for your answer.
I think it's good that you are taking this into account.

My idea is just a compromise between many levels and clarity.

I want to prevent the menu from being more than three levels deep.
And above all, I hope that it will provide an overview.
Like a separator, but with a clear indication of what's being separated.

So, you are right.

wp

  • Hero Member
  • *****
  • Posts: 12530
Re: Adding a named separator
« Reply #4 on: April 15, 2024, 01:50:10 pm »
Maybe a menu is not the kind of GUI that you need? A bit more complex is the ribbon-like TSpkToolbar which provides at least three well-separated levels of access: the ribbon tabs, the panes, and the buttons, and when you have buttons with ButtonKind bkButtonDropDown or bkDropDown you can even provide a standard dropdown menu which, of course, can have its submenus: https://wiki.freepascal.org/SpkToolbar. Several panes can be available in a tab, and each pane is labeled.

440bx

  • Hero Member
  • *****
  • Posts: 4908
Re: Adding a named separator
« Reply #5 on: April 15, 2024, 02:46:47 pm »
How I can add a named separator (menu group) to a T*Menu?
My desired sytax is - Name -.
Correct me if I'm wrong but, it sounds like what you want is to have a "title"/"heading" for some menu items.  Did I understand what you want correctly ?
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

cdbc

  • Hero Member
  • *****
  • Posts: 1787
    • http://www.cdbc.dk
Re: Adding a named separator
« Reply #6 on: April 15, 2024, 04:42:23 pm »
Hi
Use an empty(handler) menuitem with a name/caption like '---SomeName---'
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

sarad

  • Newbie
  • Posts: 5
Re: Adding a named separator
« Reply #7 on: April 15, 2024, 05:01:09 pm »
Correct me if I'm wrong but, it sounds like what you want is to have a "title"/"heading" for some menu items.
Did I understand what you want correctly ?
Exactly, that is what I want.

sarad

  • Newbie
  • Posts: 5
Re: Adding a named separator
« Reply #8 on: April 15, 2024, 05:02:18 pm »
Hi
Use an empty(handler) menuitem with a name/caption like '---SomeName---'
Regards Benny
(Like CudaText?)
No, that's ugly.

440bx

  • Hero Member
  • *****
  • Posts: 4908
Re: Adding a named separator
« Reply #9 on: April 15, 2024, 06:54:21 pm »
Exactly, that is what I want.
The only way that comes to mind to have a nice looking result is by making the menu items ownerdraw.

I'm fairly sure it can be done with the LCL but, since I know very little about the LCL, someone else will have to provide example code as to how to do ownerdrawn menu items.    With ownerdrawn menu items, the nice thing is that the "heading"/"title" doesn't get "visually selected" (different background when the mouse is on the item.)

You may find the information and example code in the following thread useful: https://forum.lazarus.freepascal.org/index.php/topic,48805.msg351924.html#msg351924

It doesn't create a "heading" but, it's likely that modifying the code a bit would allow you to implement headings.

HTH.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

sarad

  • Newbie
  • Posts: 5
Re: Adding a named separator
« Reply #10 on: May 03, 2024, 06:32:44 pm »
Thanks to all for your replies!  :D

 

TinyPortal © 2005-2018