Lazarus
Programming => LCL => Topic started by: simsee on December 10, 2016, 01:22:25 pm
-
In a GUI context, inside an event handler procedure of a TCustomControl component, I should know the state of mouse buttons. I know that Mouse.CursorPos allows to get the position and that mouse unit of RTL don't work in graphic mode. I can't use classic eventi as OnClick, OnMouseUp, OnMouseDown because I'm already inside another event handler procedure. So, how can I do? Thanks!
-
Create a variable maintaining the mouse state yourself (set, boolean array, whatever, you choose). Inside the "classic" events, mark corresponding states in the variable. In another event, check them.
-
I used a global boolean variable as a flag, that is set to True by OnMouseDown event handler and to False by OnMouseUp. I asked to the forum because I did not know if there were better solutions. Thanks again!
-
The same way you call Mouse.CursorPos you can call function GetKeyShiftState (unit Controls) and test if mouse buttons are pushed (ssLeft, ssMiddle, ssRight).
-
Thanks Blaazen. I looked at this unit, but I have not noticed this function, which unfortunately is not documented ...