Recent

Author Topic: Reactivate popupmenue after panning  (Read 1621 times)

Firebird

  • New Member
  • *
  • Posts: 26
Reactivate popupmenue after panning
« on: July 04, 2023, 12:03:33 pm »
I am using PopupMenues (right mouse button) on graphs and need to be able to enable and disable zooming and panning (right mouse button) according to what is selected in the PopupMenues. I can reactivate the PopupMenues after zooming. However, after panning I cannot reactivate the PopupMenues. My code is attached. What am I missing? Thanks for the help in advance.

wp

  • Hero Member
  • *****
  • Posts: 12457
Re: Reactivate popupmenue after panning
« Reply #1 on: July 04, 2023, 03:02:30 pm »
I can confirm this behaviour. To be honest I cannot give you an exact detailed description of what is happening, but it must be due to the fact that for the Popupmenu and the PanDragTool are using the same mouse button for activation. There is a mechanism in the ChartTools to allow using the same key for different actions. By calling PanDragtool.Handled in the right event it may be possible to pass the right-mouse-click on to the Popupmenu. However, I could not find a satifying combination; in the OnBeforeMouseUp event, for example, the popup menu did appear, but also when doing a normal drap operation...

But why so complicated? The menu and popupmenu commands in your example have the purpose to mutually interlock the zooming and dragging actions. Therefore, there is no need to assign different mouse keys to the operations. Set Shift of the PanDragTool to ssLeft (rather than ssRight), and the interference with the popup menu will be gone. Your program should work as expected.

Moveover, your sample project is a nice demonstration how code can be simplified by using Actions. Therefore, I am attaching a modified version of the code in which two TActions, acZoom and acPan, do the work of activating/deactivating the chart tools. And after assigning them to the items of the MainMenu and the PopupMenu, as well as to toolbar buttons, you get handling of these tasks for free.
« Last Edit: July 05, 2023, 12:03:29 pm by wp »

Firebird

  • New Member
  • *
  • Posts: 26
Re: Reactivate popupmenue after panning
« Reply #2 on: July 05, 2023, 09:53:35 am »
Thanks a lot for your reply WP. That is a nice and simple workaround, I could have also have thought of that one ;-)
I will look into the TActions issue, it looks like a nice tool saving quite a bit of code!

 

TinyPortal © 2005-2018