2010-03-06 15:09:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: uiaction.h
|
|
|
|
// Purpose: interface of wxUIActionSimulator
|
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2010-03-06 15:09:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxUIActionSimulator
|
|
|
|
|
|
|
|
wxUIActionSimulator is a class used to simulate user interface actions
|
2010-03-22 07:40:35 -04:00
|
|
|
such as a mouse click or a key press.
|
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
Common usage for this class would be to provide playback and record (aka
|
|
|
|
macro recording) functionality for users, or to drive unit tests by
|
|
|
|
simulating user sessions.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
See the @ref page_samples_uiaction for an example of using this class.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
@since 2.9.2
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@library{wxcore}
|
|
|
|
*/
|
|
|
|
|
|
|
|
class wxUIActionSimulator
|
|
|
|
{
|
2010-08-22 18:15:42 -04:00
|
|
|
public:
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
2010-08-22 18:15:42 -04:00
|
|
|
Default constructor.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
|
|
|
wxUIActionSimulator();
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
|
|
|
Move the mouse to the specified coordinates.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param x
|
|
|
|
x coordinate to move to, in screen coordinates.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param y
|
|
|
|
y coordinate to move to, in screen coordinates.
|
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool MouseMove(long x, long y);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Move the mouse to the specified coordinates.
|
|
|
|
|
|
|
|
@param point
|
|
|
|
Point to move to, in screen coordinates.
|
|
|
|
*/
|
|
|
|
bool MouseMove(const wxPoint& point);
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
|
|
|
Press a mouse button.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param button
|
2010-08-22 18:15:42 -04:00
|
|
|
Button to press. Valid constants are @c wxMOUSE_BTN_LEFT,
|
|
|
|
@c wxMOUSE_BTN_MIDDLE, and @c wxMOUSE_BTN_RIGHT.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool MouseDown(int button = wxMOUSE_BTN_LEFT);
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
|
|
|
Release a mouse button.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param button
|
2010-08-22 18:15:42 -04:00
|
|
|
Button to press. See wxUIActionSimulator::MouseDown for a list of
|
|
|
|
valid constants.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool MouseUp(int button = wxMOUSE_BTN_LEFT);
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
|
|
|
Click a mouse button.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param button
|
2010-08-22 18:15:42 -04:00
|
|
|
Button to press. See wxUIActionSimulator::MouseDown for a list of
|
|
|
|
valid constants.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool MouseClick(int button = wxMOUSE_BTN_LEFT);
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
|
|
|
Double-click a mouse button.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param button
|
2010-08-22 18:15:42 -04:00
|
|
|
Button to press. See wxUIActionSimulator::MouseDown for a list of
|
|
|
|
valid constants.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool MouseDblClick(int button = wxMOUSE_BTN_LEFT);
|
2010-03-06 15:09:23 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Perform a drag and drop operation.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param x1
|
|
|
|
x start coordinate, in screen coordinates.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param y1
|
|
|
|
y start coordinate, in screen coordinates.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param x2
|
2011-04-03 16:31:32 -04:00
|
|
|
x destination coordinate, in screen coordinates.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param y2
|
|
|
|
y destination coordinate, in screen coordinates.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param button
|
2010-08-22 18:15:42 -04:00
|
|
|
Button to press. See wxUIActionSimulator::MouseDown for a list of
|
|
|
|
valid constants.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool MouseDragDrop(long x1, long y1, long x2, long y2,
|
|
|
|
int button = wxMOUSE_BTN_LEFT);
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
2010-03-22 07:40:35 -04:00
|
|
|
Press a key.
|
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
If you are using modifiers then it needs to be paired with an identical
|
2015-06-04 18:54:02 -04:00
|
|
|
KeyUp or the modifiers will not be released (MSW and OS X).
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
@param keycode
|
|
|
|
Key to operate on, as an integer. It is interpreted as a wxKeyCode.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
@param modifiers
|
|
|
|
A combination of ::wxKeyModifier flags to be pressed with the given
|
|
|
|
keycode.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool KeyDown(int keycode, int modifiers = wxMOD_NONE);
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
2010-03-22 07:40:35 -04:00
|
|
|
Release a key.
|
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param keycode
|
2010-08-22 18:15:42 -04:00
|
|
|
Key to operate on, as an integer. It is interpreted as a wxKeyCode.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
@param modifiers
|
|
|
|
A combination of ::wxKeyModifier flags to be pressed with the given
|
|
|
|
keycode.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool KeyUp(int keycode, int modifiers = wxMOD_NONE);
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
/**
|
2010-03-22 07:40:35 -04:00
|
|
|
Press and release a key.
|
|
|
|
|
2010-03-06 15:09:23 -05:00
|
|
|
@param keycode
|
2010-08-22 18:15:42 -04:00
|
|
|
Key to operate on, as an integer. It is interpreted as a wxKeyCode.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
@param modifiers
|
|
|
|
A combination of ::wxKeyModifier flags to be pressed with the given
|
|
|
|
keycode.
|
|
|
|
*/
|
|
|
|
bool Char(int keycode, int modifiers = wxMOD_NONE);
|
|
|
|
|
2014-09-10 12:52:01 -04:00
|
|
|
/**
|
|
|
|
Simulate selection of an item with the given text.
|
|
|
|
|
|
|
|
This method selects an item in the currently focused wxChoice,
|
|
|
|
wxComboBox, wxListBox and similar controls. It does it by simulating
|
|
|
|
keyboard events, so the behaviour should be the same as if the item
|
|
|
|
was really selected by the user.
|
|
|
|
|
|
|
|
Notice that the implementation of this method uses wxYield() and so
|
|
|
|
events can be dispatched from it.
|
|
|
|
|
|
|
|
@param text
|
|
|
|
The text of the item to select.
|
|
|
|
|
|
|
|
@return
|
|
|
|
@true if the item @a text was successfully selected or @false if
|
|
|
|
the currently focused window is not one of the controls allowing
|
|
|
|
item selection or if the item with the given text was not found in
|
|
|
|
it.
|
|
|
|
|
|
|
|
@since 3.1.0
|
|
|
|
*/
|
|
|
|
bool Select(const wxString& text);
|
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
/**
|
|
|
|
Emulate typing in the keys representing the given string.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2015-02-14 19:02:00 -05:00
|
|
|
Currently only the ASCII letters are universally supported. Digits and
|
|
|
|
punctuation characters can be used with the standard QWERTY (US)
|
|
|
|
keyboard layout but may not work with other layouts.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
@param text
|
|
|
|
The string to type.
|
2010-03-06 15:09:23 -05:00
|
|
|
*/
|
2010-08-22 18:15:42 -04:00
|
|
|
bool Text(const wxString& text);
|
2010-03-06 15:09:23 -05:00
|
|
|
};
|
|
|
|
|