Class: Wx::UIActionSimulator

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/doc/gen/ui_action_simulator.rb

Overview

Note:

This class is untracked and should not be derived from nor instances extended!

UIActionSimulator is a class used to simulate user interface actions such as a mouse click or a key press.

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. See the wxUIActionSimulator Sample for an example of using this class.

Note:

This class currently doesn't work when using Wayland with WXGTK.

Requires:

  • USE_UIACTIONSIMULATOR

Instance Method Summary collapse

Constructor Details

#initializeWx::UIActionSimulator

Default constructor.



27
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 27

def initialize; end

Instance Method Details

#char(keycode, modifiers = Wx::KeyModifier::MOD_NONE) ⇒ Boolean

Press and release a key.

Parameters:

  • keycode (Integer)

    Key to operate on, as an integer. It is interpreted as a KeyCode.

  • modifiers (Integer) (defaults to: Wx::KeyModifier::MOD_NONE)

    A combination of KeyModifier flags to be pressed with the given keycode.

Returns:

  • (Boolean)


87
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 87

def char(keycode, modifiers=Wx::KeyModifier::MOD_NONE) end

#key_down(keycode, modifiers = Wx::KeyModifier::MOD_NONE) ⇒ Boolean

Press a key.

If you are using modifiers then it needs to be paired with an identical KeyUp or the modifiers will not be released (MSW and macOS).

Parameters:

  • keycode (Integer)

    Key to operate on, as an integer. It is interpreted as a KeyCode.

  • modifiers (Integer) (defaults to: Wx::KeyModifier::MOD_NONE)

    A combination of KeyModifier flags to be pressed with the given keycode.

Returns:

  • (Boolean)


75
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 75

def key_down(keycode, modifiers=Wx::KeyModifier::MOD_NONE) end

#key_up(keycode, modifiers = Wx::KeyModifier::MOD_NONE) ⇒ Boolean

Release a key.

Parameters:

  • keycode (Integer)

    Key to operate on, as an integer. It is interpreted as a KeyCode.

  • modifiers (Integer) (defaults to: Wx::KeyModifier::MOD_NONE)

    A combination of KeyModifier flags to be pressed with the given keycode.

Returns:

  • (Boolean)


81
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 81

def key_up(keycode, modifiers=Wx::KeyModifier::MOD_NONE) end

#mouse_click(button = Wx::MouseButton::MOUSE_BTN_LEFT) ⇒ Boolean

Click a mouse button.

Parameters:

  • button (Integer) (defaults to: Wx::MouseButton::MOUSE_BTN_LEFT)

    Button to press. See #mouse_down for a list of valid constants.

Returns:

  • (Boolean)


53
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 53

def mouse_click(button=Wx::MouseButton::MOUSE_BTN_LEFT) end

#mouse_dbl_click(button = Wx::MouseButton::MOUSE_BTN_LEFT) ⇒ Boolean

Double-click a mouse button.

Parameters:

  • button (Integer) (defaults to: Wx::MouseButton::MOUSE_BTN_LEFT)

    Button to press. See #mouse_down for a list of valid constants.

Returns:

  • (Boolean)


58
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 58

def mouse_dbl_click(button=Wx::MouseButton::MOUSE_BTN_LEFT) end

#mouse_down(button = Wx::MouseButton::MOUSE_BTN_LEFT) ⇒ Boolean

Press a mouse button.

Parameters:

Returns:

  • (Boolean)


43
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 43

def mouse_down(button=Wx::MouseButton::MOUSE_BTN_LEFT) end

#mouse_drag_drop(x1, y1, x2, y2, button = Wx::MouseButton::MOUSE_BTN_LEFT) ⇒ Boolean

Perform a drag and drop operation.

Parameters:

  • x1 (Integer)

    x start coordinate, in screen coordinates.

  • y1 (Integer)

    y start coordinate, in screen coordinates.

  • x2 (Integer)

    x destination coordinate, in screen coordinates.

  • y2 (Integer)

    y destination coordinate, in screen coordinates.

  • button (Integer) (defaults to: Wx::MouseButton::MOUSE_BTN_LEFT)

    Button to press. See #mouse_down for a list of valid constants.

Returns:

  • (Boolean)


67
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 67

def mouse_drag_drop(x1, y1, x2, y2, button=Wx::MouseButton::MOUSE_BTN_LEFT) end

#mouse_move(x, y) ⇒ Boolean #mouse_move(point) ⇒ Boolean

Overloads:

  • #mouse_move(x, y) ⇒ Boolean

    Move the mouse to the specified coordinates.

    Parameters:

    • x (Integer)

      x coordinate to move to, in screen coordinates.

    • y (Integer)

      y coordinate to move to, in screen coordinates.

    Returns:

    • (Boolean)
  • #mouse_move(point) ⇒ Boolean

    Move the mouse to the specified coordinates.

    Parameters:

    • point (Array(Integer, Integer), Wx::Point)

      Point to move to, in screen coordinates.

    Returns:

    • (Boolean)


38
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 38

def mouse_move(*args) end

#mouse_up(button = Wx::MouseButton::MOUSE_BTN_LEFT) ⇒ Boolean

Release a mouse button.

Parameters:

  • button (Integer) (defaults to: Wx::MouseButton::MOUSE_BTN_LEFT)

    Button to press. See #mouse_down for a list of valid constants.

Returns:

  • (Boolean)


48
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 48

def mouse_up(button=Wx::MouseButton::MOUSE_BTN_LEFT) end

#select(text) ⇒ Boolean

Simulate selection of an item with the given text.

This method selects an item in the currently focused Choice, ComboBox, ListBox 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 yield and so events can be dispatched from it.

true if the item 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.

Parameters:

  • text (String)

    The text of the item to select.

Returns:

  • (Boolean)


97
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 97

def select(text) end

#text(text) ⇒ Boolean

Emulate typing in the keys representing the given string.

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.

Parameters:

  • text (String)

    The string, containing only US ASCII characters, to type.

Returns:

  • (Boolean)


104
# File 'lib/wx/doc/gen/ui_action_simulator.rb', line 104

def text(text) end