]>
Commit | Line | Data |
---|---|---|
a02a5cfc KO |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: uiaction.h | |
3 | // Purpose: interface of wxUIActionSimulator | |
4 | // Author: wxWidgets team | |
526954c5 | 5 | // Licence: wxWindows licence |
a02a5cfc KO |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
8 | /** | |
9 | @class wxUIActionSimulator | |
10 | ||
11 | wxUIActionSimulator is a class used to simulate user interface actions | |
9b7e0226 VZ |
12 | such as a mouse click or a key press. |
13 | ||
571d991b VZ |
14 | Common usage for this class would be to provide playback and record (aka |
15 | macro recording) functionality for users, or to drive unit tests by | |
16 | simulating user sessions. | |
9b7e0226 | 17 | |
571d991b | 18 | See the @ref page_samples_uiaction for an example of using this class. |
9b7e0226 | 19 | |
571d991b | 20 | @since 2.9.2 |
9b7e0226 | 21 | |
a02a5cfc KO |
22 | @library{wxcore} |
23 | */ | |
24 | ||
25 | class wxUIActionSimulator | |
26 | { | |
571d991b | 27 | public: |
a02a5cfc | 28 | /** |
571d991b | 29 | Default constructor. |
a02a5cfc KO |
30 | */ |
31 | wxUIActionSimulator(); | |
9b7e0226 | 32 | |
a02a5cfc KO |
33 | /** |
34 | Move the mouse to the specified coordinates. | |
9b7e0226 | 35 | |
a02a5cfc KO |
36 | @param x |
37 | x coordinate to move to, in screen coordinates. | |
9b7e0226 | 38 | |
a02a5cfc KO |
39 | @param y |
40 | y coordinate to move to, in screen coordinates. | |
41 | */ | |
571d991b VZ |
42 | bool MouseMove(long x, long y); |
43 | ||
44 | /** | |
45 | Move the mouse to the specified coordinates. | |
46 | ||
47 | @param point | |
48 | Point to move to, in screen coordinates. | |
49 | */ | |
50 | bool MouseMove(const wxPoint& point); | |
9b7e0226 | 51 | |
a02a5cfc KO |
52 | /** |
53 | Press a mouse button. | |
9b7e0226 | 54 | |
a02a5cfc | 55 | @param button |
571d991b VZ |
56 | Button to press. Valid constants are @c wxMOUSE_BTN_LEFT, |
57 | @c wxMOUSE_BTN_MIDDLE, and @c wxMOUSE_BTN_RIGHT. | |
a02a5cfc | 58 | */ |
571d991b | 59 | bool MouseDown(int button = wxMOUSE_BTN_LEFT); |
9b7e0226 | 60 | |
a02a5cfc KO |
61 | /** |
62 | Release a mouse button. | |
9b7e0226 | 63 | |
a02a5cfc | 64 | @param button |
571d991b VZ |
65 | Button to press. See wxUIActionSimulator::MouseDown for a list of |
66 | valid constants. | |
a02a5cfc | 67 | */ |
571d991b | 68 | bool MouseUp(int button = wxMOUSE_BTN_LEFT); |
a02a5cfc KO |
69 | /** |
70 | Click a mouse button. | |
9b7e0226 | 71 | |
a02a5cfc | 72 | @param button |
571d991b VZ |
73 | Button to press. See wxUIActionSimulator::MouseDown for a list of |
74 | valid constants. | |
a02a5cfc | 75 | */ |
571d991b | 76 | bool MouseClick(int button = wxMOUSE_BTN_LEFT); |
a02a5cfc KO |
77 | /** |
78 | Double-click a mouse button. | |
9b7e0226 | 79 | |
a02a5cfc | 80 | @param button |
571d991b VZ |
81 | Button to press. See wxUIActionSimulator::MouseDown for a list of |
82 | valid constants. | |
a02a5cfc | 83 | */ |
571d991b | 84 | bool MouseDblClick(int button = wxMOUSE_BTN_LEFT); |
a02a5cfc KO |
85 | |
86 | /** | |
87 | Perform a drag and drop operation. | |
9b7e0226 | 88 | |
a02a5cfc KO |
89 | @param x1 |
90 | x start coordinate, in screen coordinates. | |
9b7e0226 | 91 | |
a02a5cfc KO |
92 | @param y1 |
93 | y start coordinate, in screen coordinates. | |
9b7e0226 | 94 | |
a02a5cfc | 95 | @param x2 |
d13b34d3 | 96 | x destination coordinate, in screen coordinates. |
9b7e0226 | 97 | |
a02a5cfc KO |
98 | @param y2 |
99 | y destination coordinate, in screen coordinates. | |
9b7e0226 | 100 | |
a02a5cfc | 101 | @param button |
571d991b VZ |
102 | Button to press. See wxUIActionSimulator::MouseDown for a list of |
103 | valid constants. | |
a02a5cfc | 104 | */ |
571d991b VZ |
105 | bool MouseDragDrop(long x1, long y1, long x2, long y2, |
106 | int button = wxMOUSE_BTN_LEFT); | |
9b7e0226 | 107 | |
a02a5cfc | 108 | /** |
9b7e0226 VZ |
109 | Press a key. |
110 | ||
571d991b VZ |
111 | If you are using modifiers then it needs to be paired with an identical |
112 | KeyUp or the modifiers will not be released (MSW and OSX). | |
9b7e0226 | 113 | |
571d991b VZ |
114 | @param keycode |
115 | Key to operate on, as an integer. It is interpreted as a wxKeyCode. | |
9b7e0226 | 116 | |
571d991b VZ |
117 | @param modifiers |
118 | A combination of ::wxKeyModifier flags to be pressed with the given | |
119 | keycode. | |
a02a5cfc | 120 | */ |
571d991b | 121 | bool KeyDown(int keycode, int modifiers = wxMOD_NONE); |
9b7e0226 | 122 | |
a02a5cfc | 123 | /** |
9b7e0226 VZ |
124 | Release a key. |
125 | ||
a02a5cfc | 126 | @param keycode |
571d991b | 127 | Key to operate on, as an integer. It is interpreted as a wxKeyCode. |
9b7e0226 | 128 | |
571d991b VZ |
129 | @param modifiers |
130 | A combination of ::wxKeyModifier flags to be pressed with the given | |
131 | keycode. | |
a02a5cfc | 132 | */ |
571d991b | 133 | bool KeyUp(int keycode, int modifiers = wxMOD_NONE); |
9b7e0226 | 134 | |
a02a5cfc | 135 | /** |
9b7e0226 VZ |
136 | Press and release a key. |
137 | ||
a02a5cfc | 138 | @param keycode |
571d991b | 139 | Key to operate on, as an integer. It is interpreted as a wxKeyCode. |
9b7e0226 | 140 | |
571d991b VZ |
141 | @param modifiers |
142 | A combination of ::wxKeyModifier flags to be pressed with the given | |
143 | keycode. | |
144 | */ | |
145 | bool Char(int keycode, int modifiers = wxMOD_NONE); | |
146 | ||
147 | /** | |
148 | Emulate typing in the keys representing the given string. | |
9b7e0226 | 149 | |
c0c9009c VZ |
150 | Currently only the ASCII letters, digits and characters for the definition |
151 | of numbers (i.e. characters @c a-z @c A-Z @c 0-9 @c + @c - @c . @c , @c 'space') | |
571d991b | 152 | are supported. |
9b7e0226 | 153 | |
571d991b VZ |
154 | @param text |
155 | The string to type. | |
a02a5cfc | 156 | */ |
571d991b | 157 | bool Text(const wxString& text); |
a02a5cfc KO |
158 | }; |
159 |