Line | |
---|
1 | unit Os.Mouse;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Os.Types;
|
---|
7 |
|
---|
8 | type
|
---|
9 | TMouseButton = (mbLeft, mbMiddle, mbRight);
|
---|
10 |
|
---|
11 | TButtonEvent = procedure (Pos: TPosition; Button: TMouseButton) of object;
|
---|
12 | TMoveEvent = procedure (Pos: TPosition) of object;
|
---|
13 |
|
---|
14 | { TMouse }
|
---|
15 |
|
---|
16 | TMouse = class
|
---|
17 | private
|
---|
18 | FOnButtonDown: TButtonEvent;
|
---|
19 | FOnButtonUp: TButtonEvent;
|
---|
20 | FOnMove: TMoveEvent;
|
---|
21 | public
|
---|
22 | procedure ButtonDown(Pos: TPosition; Button: TMouseButton);
|
---|
23 | procedure ButtonUp(Pos: TPosition; Button: TMouseButton);
|
---|
24 | procedure Move(Pos: TPosition);
|
---|
25 | property OnButtonDown: TButtonEvent read FOnButtonDown write FOnButtonDown;
|
---|
26 | property OnButtonUp: TButtonEvent read FOnButtonUp write FOnButtonUp;
|
---|
27 | property OnMove: TMoveEvent read FOnMove write FOnMove;
|
---|
28 | end;
|
---|
29 |
|
---|
30 |
|
---|
31 | implementation
|
---|
32 |
|
---|
33 | { TMouse }
|
---|
34 |
|
---|
35 | procedure TMouse.ButtonDown(Pos: TPosition; Button: TMouseButton);
|
---|
36 | begin
|
---|
37 | if Assigned(FOnButtonDown) then
|
---|
38 | FOnButtonDown(Pos, Button);
|
---|
39 | end;
|
---|
40 |
|
---|
41 | procedure TMouse.ButtonUp(Pos: TPosition; Button: TMouseButton);
|
---|
42 | begin
|
---|
43 | if Assigned(FOnButtonUp) then
|
---|
44 | FOnButtonUp(Pos, Button);
|
---|
45 | end;
|
---|
46 |
|
---|
47 | procedure TMouse.Move(Pos: TPosition);
|
---|
48 | begin
|
---|
49 | if Assigned(FOnMove) then
|
---|
50 | FOnMove(Pos);
|
---|
51 | end;
|
---|
52 |
|
---|
53 | end.
|
---|
54 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.