On 07/04/2010 14:46, Kjow wrote:
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?

I wouldn't recommend that change. Some units define
  const  Foo = Array [TMouseButton] of String = (list of names for values);

Those will break, because the count of the enum changed.

Create a set

type
  TMouseButtons = set of  TMouseButton ;
var
  MouseButtonPressed: TMouseButtons;

MouseButtonPressed := [];
MouseButtonPressed := [mbLeft];
MouseButtonPressed := [mbLeft, mbRight];

and so on

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to