2010-03-06 15:09:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: uiaction.h
|
|
|
|
// Purpose: interface of wxUIActionSimulator
|
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
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
|
|
|
|
x desintation 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
|
|
|
|
KeyUp or the modifiers will not be released (MSW and OSX).
|
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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Emulate typing in the keys representing the given string.
|
2010-03-22 07:40:35 -04:00
|
|
|
|
2010-08-22 18:15:42 -04:00
|
|
|
Currently only the ASCII letters (i.e. characters @c a-z and @c A-Z)
|
|
|
|
are supported.
|
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
|
|
|
};
|
|
|
|
|