$click » History » Version 1
Per Amundsen, 08/14/2014 04:40 AM
1 | 1 | Per Amundsen | _Added in 1.9.4_ |
---|---|---|---|
2 | |||
3 | *$click(@window, N)* |
||
4 | |||
5 | Retrieves mouse click information from a picture window. |
||
6 | |||
7 | If no properties is defined, returns both X Y. |
||
8 | |||
9 | *Parameters* |
||
10 | |||
11 | @window - Picture window to use. |
||
12 | N - The N'th mouse click item, if N = 0, returns number of mouse click items. |
||
13 | |||
14 | *Properties* |
||
15 | |||
16 | .x - Returns the X coordinate of the mouse click. |
||
17 | .y - Returns the Y coordinate of the mouse click. |
||
18 | |||
19 | *Example* |
||
20 | |||
21 | <pre> |
||
22 | ; Create the custom alias to launch the example |
||
23 | ; |
||
24 | ; Synopsis: /clickWatch |
||
25 | |||
26 | alias clickWatch { |
||
27 | ;Create a custom picture window, which is centered. |
||
28 | window -dpC @clicker 0 0 250 125 |
||
29 | |||
30 | ;Custom 'update' alias keeps code from repeating. |
||
31 | ;During initial launch the values should be empty. |
||
32 | update 15 Total Clicks: empty |
||
33 | update 35 Current Position: none yet |
||
34 | update 55 Previous Position: none yet |
||
35 | } |
||
36 | ;Monitor the sclicks in our custom '@clicker' window. |
||
37 | menu @clicker { |
||
38 | sclick: { |
||
39 | |||
40 | ;Clear the window for the new value updates. |
||
41 | clear @clicker |
||
42 | |||
43 | ;Set the %current and %prev variables to the current. |
||
44 | ;x/y click location, and to the previous x/y click. |
||
45 | ;locations, respectively. |
||
46 | var %current = $click(@clicker,0), %prev = $calc(%current - 1) |
||
47 | |||
48 | ;Utilizing the custom 'update' alias, update the data. |
||
49 | update 15 Total Clicks: $click(@clicker,0) |
||
50 | update 35 Current Position: $click(@clicker,%current) |
||
51 | update 55 Previous Position: $iif(%prev,$click(@clicker,%prev),none yet) |
||
52 | } |
||
53 | } |
||
54 | ;Custom update alias removes a lot of the /drawtext repetition. |
||
55 | ;from this example. |
||
56 | alias -l update { |
||
57 | drawtext @clicker $color(normal) 7 $1 $2- |
||
58 | } |
||
59 | </pre> |