[Lazarus] TMouseButton

Vincent Snijders vsnijders at vodafonevast.nl
Wed Apr 7 15:54:49 CEST 2010


Kjow schreef:
> Hi all,
> 
> I need to create an "advanced" function that manages mouse events, so
> I need to know when/which a button is pressed and so, when no button
> is pressed.
> I saw that in TMouseButton (row 142 of Controls unit) there isn't
> mbNone, so I simply edited that row:
> 
> TMouseButton = (mbNone, mbLeft, mbRight, mbMiddle, mbExtra1, mbExtra2);
> 
> Now I can see when no buttons are pressed; I simply manage it with
> 
> MouseButtonPressed:=Button; //OnMouseDown
> 
> MouseButtonPressed:=mbNone; //OnMouseUp
> 
> Now the question: there is a better way to do this whitout modify the
> Lazarus source code? It is a bug/missing feature or this is a feature?
>

What about:

type
   TMouseButtons = set of TMouseButton; // if it doesn't exist yet

var
   MouseButtonPressed: TMouseButtons;


 > MouseButtonPressed:=MouseButtonPressed + Button; //OnMouseDown

Your mbNone becomes:
 > MouseButtonPressed:=[];

Vincent




More information about the Lazarus mailing list