Author: Jorge Abel Ayala Marentes
How to known if the user has pressed simultaneously the left and right mouse
buttons?
Answer:
The OnMouse event is declared as follows:
1 2 procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
3 Shift: TShiftState; X, Y: Integer);
4 5 if you find in the Classes unit the declaration of TShiftState is:
6 7 TShiftState = setof (ssShift, ssAlt, ssCtrl,
8 ssLeft, ssRight, ssMiddle, ssDouble);
9 10 So you need to test if sLeft and ssRight are present in the Shift parameter, now
11 your code must be like this:
12 13 procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
14 Shift: TShiftState; X, Y: Integer);
15 begin16 if (ssRight in Shift) and (ssLeft in Shift) then17 ShowMessage('The user has pressed Left and Right buttons');
18 end;