Recent

Author Topic: Behaviour of TPopupMenu.OnClick  (Read 723 times)

staratel20

  • Full Member
  • ***
  • Posts: 203
Behaviour of TPopupMenu.OnClick
« on: January 16, 2020, 11:59:22 pm »
When I create the dispatcher of PopupMenu TMenuItem.OnClick which is have submenu from right , it actually appears on event OnMouseEnter (or more correct to say - SubMenu.OnShow), which is obviously, not the same. That will be good to bring TPopupMenu.OnMouseDown , TPopupMenu.OnMouseUp , OnMouseEnter, OnMouseLeave. The behaviour of TPopupMenu.OnClick could be the same for good compatibility with Delphi projects.

Gonna explain the main thing - What for?
For example I need to check and uncheck TMenuItem by Clicking on it, but the right submenu of this item - it is some options, that affects if only TMenuItem checked

Thank you for attention
« Last Edit: January 17, 2020, 12:02:09 am by staratel20 »
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

jamie

  • Hero Member
  • *****
  • Posts: 2313
Re: Behaviour of TPopupMenu.OnClick
« Reply #1 on: January 17, 2020, 12:17:02 am »
Maybe you need the "AutoPopUp := False " ?
Number 1 at blue screen app creations!

lucamar

  • Hero Member
  • *****
  • Posts: 2409
Re: Behaviour of TPopupMenu.OnClick
« Reply #2 on: January 17, 2020, 12:39:30 pm »
I on't exactly understand what's your problem but just in case, you can (un-)check items automatically by setting their AutoCheck property to True.

To set the Checked state from code you should do it either in the menu OnPopUp event, for items in the starting popup, or in the submenu's "parent" item OnClick

Just to make sure: your problem is that the sub-menu is shown before the "parent" OnClick event is fired?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

staratel20

  • Full Member
  • ***
  • Posts: 203
Re: Behaviour of TPopupMenu.OnClick
« Reply #3 on: January 18, 2020, 10:50:38 pm »
jamie: no, I want AutoPopup, but I don't want component use auto-popup event like clicking event. For me it almost the same like to use OnMouseEnter like OnMouseClick with only delay difference

lucamar: I need to analyze your answer a little longer, please give me some time to reply.

This time thanks. Any other ideas - also good)
« Last Edit: January 18, 2020, 11:49:21 pm by staratel20 »
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

jamie

  • Hero Member
  • *****
  • Posts: 2313
Re: Behaviour of TPopupMenu.OnClick
« Reply #4 on: January 18, 2020, 11:47:49 pm »
I appears you are looking for additional event triggers to be added to the menus ?

 I just looked at the online Delphi help and I don't see anything there that Lazarus does not have..

 You could hook into the Window of the PopupMenu and handle the events but then it won't be cross platform.
Number 1 at blue screen app creations!

staratel20

  • Full Member
  • ***
  • Posts: 203
Re: Behaviour of TPopupMenu.OnClick
« Reply #5 on: January 18, 2020, 11:50:47 pm »
Yes jamie, this time you're right. And it sad for me to hear it...
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

staratel20

  • Full Member
  • ***
  • Posts: 203
Re: Behaviour of TPopupMenu.OnClick
« Reply #6 on: January 21, 2020, 12:53:05 pm »
Also I still think that this is very, very wrong. Because the name of event not corresponds to what really happen
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming