Recent

Author Topic: Close a PopupMenu with mouselick?  (Read 1879 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Close a PopupMenu with mouselick?
« on: October 20, 2018, 05:18:27 pm »
Hi All,

I have a Popupmenu which pops up at the mouse location as expected.

However, when I click elsewhere the menu is moved and my main form does not receive the mouse click?

Is there a way to close the popup so that the main form takes the click?


Thanks in advance.

ASerge

  • Hero Member
  • *****
  • Posts: 2212
Re: Close a PopupMenu with mouselick?
« Reply #1 on: October 20, 2018, 06:39:37 pm »
However, when I click elsewhere the menu is moved and my main form does not receive the mouse click?
Is there a way to close the popup so that the main form takes the click?
Moved? What you do? When I click on the form menu disappears.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Close a PopupMenu with mouselick?
« Reply #2 on: October 22, 2018, 10:24:08 am »
I think I know what's happening, but better put sample code to confirm.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: Close a PopupMenu with mouselick?
« Reply #3 on: October 22, 2018, 06:16:33 pm »
I guess that would happen if you don't first test to see if the menu is already showing....

 if you keep calling the PopUp(X,Y) each time a mouse click takes place it'll just move around.
 
 I guess it's  a trick to find out if the menu is already showing ?

 I guess on could try this, not sure if it will work.

 if Not isWindowVisible(MyPopUpMenu.handle) Then PopUp(X,Y).

 Normally most use the right click to do this..

Or just set a flag in the OnPopUp to indicate it's already opened and clear it in the OnClose event..
« Last Edit: October 22, 2018, 06:18:42 pm by jamie »
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018