Recent

Author Topic: [solved]How to popup submenu from a popupmenu?  (Read 6192 times)

SunyD

  • Guest
[solved]How to popup submenu from a popupmenu?
« on: September 11, 2017, 02:42:34 pm »
I have a popmenu and one menuitem from this popmenu has submenu. Look at picture.
The submenu should be visible at the beginning like in the screenshot.
How can I do this?
PopupMenu.Popup shows only first level.

« Last Edit: September 11, 2017, 04:59:35 pm by Soner A. »

SunyD

  • Guest
Re: How to popup submenu from a popupmenu?
« Reply #1 on: September 11, 2017, 02:43:25 pm »
I forget screenshot, here is it:

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: How to popup submenu from a popupmenu?
« Reply #2 on: September 11, 2017, 02:50:08 pm »
On your Menu Editor > right click > and choose: "Create Submenu". It is same for main menu and pop up menu. Tested on Linux Gtk2, it works correctly.
« Last Edit: September 11, 2017, 02:57:26 pm by Handoko »

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: How to popup submenu from a popupmenu?
« Reply #3 on: September 11, 2017, 03:15:53 pm »
It is same for main menu and pop up menu.
@Handoko, I don't think the question was "who to make a submenu" but how can I show the submenu automatically on opening the popupmenu.

@Soner A., I don't think this is possible, other than selecting the parent-item of that submenu during opening.

You might be able to use virtual mouse-click at that position to open up the submenu but the moment you move the mouse, the submenu closes if the mouse is nog over "New Item 3".

Why exactly do you want this abnormal popupmenu behavior? Maybe there are some better alternatives.

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: How to popup submenu from a popupmenu?
« Reply #4 on: September 11, 2017, 03:31:11 pm »
I agree with you, that behavior is abnormal. It will confuse users.

SunyD

  • Guest
Re: How to popup submenu from a popupmenu?
« Reply #5 on: September 11, 2017, 04:35:59 pm »
Thanks for the answers. I use the menuitems like checkbox to show and hide grid-columns.
I know the normal way is popup dialog and I will impllement it later, but the menus were there. I try to use it with less mouse move and clicks. When the user holds the [ctrl]-Key down at selecting some menuitem then the menu shows again and the user can click again.
This question is not very important, I wanted only know if it is possible.

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: How to popup submenu from a popupmenu?
« Reply #6 on: September 11, 2017, 04:45:51 pm »
I never tried but in theory it is possible. I ever tried lazmouseandkeyinput.lpk to simulate mouse move and click. So you can write the code to move your mouse pointer to hover at the submenu item, then the submenu should be popup.

http://forum.lazarus.freepascal.org/index.php/topic,37305.msg250408.html#msg250408

SunyD

  • Guest
Re: How to popup submenu from a popupmenu?
« Reply #7 on: September 11, 2017, 04:53:26 pm »
Moving the mousecursor is not good. It confuse the user.

I got it now at least on windows. I can remeber that I made it years ago with delphi.
This is it:
Code: Pascal  [Select][+][-]
  1. uses Windows; //for TrackPopupMenu and TPM_..
  2. procedure TForm1.Sub11Click(Sender: TObject);
  3. begin
  4.   TrackPopupMenu(miCat.Handle,TPM_LEFTALIGN or TPM_TOPALIGN, Mouse.CursorPos.x,Mouse.CursorPos.y,0, Handle,nil);
  5. end;
  6.  

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: How to popup submenu from a popupmenu?
« Reply #8 on: September 11, 2017, 04:56:31 pm »
On my Linux Lazarus, I can't find TrackPopupMenu. But I think it is okay on Windows:
http://forum.lazarus.freepascal.org/index.php?topic=37369.0

SunyD

  • Guest
Re: [solved]How to popup submenu from a popupmenu?
« Reply #9 on: September 11, 2017, 05:02:07 pm »
TrackPopupMenu is from window-api. It is same as TPopupMenu.PopUp(...).
The difference is you can use TrackPopupMenu with every menuitem.

 

TinyPortal © 2005-2018