Mouse handling in TTree

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Lenfors
Newbie
Newbie
Posts: 1
Joined: Wed Sep 25, 2024 12:00 am

Mouse handling in TTree

Post by Lenfors » Mon Nov 25, 2024 7:06 pm

Hello!

In the TTree component I set the ScrollMouseButton to mbRight. If i right click on the TTree and drag it moves the entire workarea as expected.
I also have an OnClickShape event where i check if it's a mbRight button pressed and if that's the case i show a popup menu.
After selecting a function in the popup menu the TTree is someway still hooked to the mouse, so when i move the mouse (without pressing any mouse button) the entire workare moves as if I was "Right mouse button" moving.

Any idea how to prevent this?

I want the "right button move" function to work as usual, but when right clicking a TTreeNodeShape there should be no movement.

Best regards, Mikael

ags
Newbie
Newbie
Posts: 2
Joined: Wed May 18, 2022 12:00 am

Re: Mouse handling in TTree

Post by ags » Thu Dec 19, 2024 4:40 pm

Hi Mikael

Maybe you could use TTree.CancelMouse in the MouseMove event to stop the "sticky mouse".

If you add a state variable "mbRightIsPressed" to your form and set it in the Tree.OnMouseDown event handler:

Code: Select all

  mbRightIsPressed := (Button = TMouseButton.mbRight);
and reset the variable in the Tree.OnMouseUp event:

Code: Select all

  mbRightIsPressed := False;
Then you could test if any mousebutton(s) are pressed in the Tree.OnMouseMove event, and if nothing is pressed then you use CancelMouse like this:

Code: Select all

if (not mbRightIsPressed) then
  Tree1.CancelMouse := True;

Post Reply