Mouse event: event when the mouse is pressed, released, dragged or moved. More...
Public Member Functions | |
GMouseEvent & | asMouseEvent () override |
Returns the event casted to the specified event subclass. More... | |
GMouseEvent * | toMouseEvent () override |
Returns the event casted to the specified event subclass. More... | |
int | button () const |
Returns the button that was just pressed or released. More... | |
int | clickCount () const |
Returns the number of mouse clicks on click events. More... | |
GEventState | state () const |
Returns an ORed combination of buttons and modifiers; see GEvent::States. More... | |
void | redirectEvent (Gadget &to_gadget) |
Redirects the event to this gadget. More... | |
Gadget * | chosen () const |
Returns the checked child of a box that enforces exclusive selection. More... | |
GWindow * | window () const |
Returns the window where this event occured. | |
GTrigger const & | trigger () const |
Returns the trigger that fired this event. | |
GEventType | eventMask () const |
Returns the event mask. | |
int | channel () const |
Returns the input channel. More... | |
GTime | time () const |
Returns the timestamp. More... | |
void | postFire (std::function< void(GEvent &)> const &todo_after) |
Sets a function that is called after firing all callbacks trigerred by a same event. | |
int | matches (GTrigger const &trigger, int channel) const |
Returns a non-zero value if this trigger matches this event. | |
GPoint | pos () const |
Returns the position relative to the sender(). | |
const GPoint & | wpos () const |
Returns the position relative to the window(). | |
float | dx () const |
Returns the displacement from last GMouseEvent. More... | |
bool | shiftPressed () const |
Returns the modifier keys that are currently pressed. | |
Gadget & | from () const |
Returns where this event occured. More... | |
GObject * | tag () const |
Changes/returns the event tag. More... | |
Static Public Member Functions | |
static GEventState | buttonToState (int mouse_button) |
Converts a mouse button number into an event state. More... | |
static GEventState | modifierToState (GKeyCode modifier_key) |
Converts a modifier keycode intoto an event state. | |
static GEventState | modifiersToStates (GString const &modifiers) |
Converts a combination of modifier names to ORed modifier states. More... | |
static void | setMouseButtonHandler (int channel, std::function< bool(class GMouseEvent &)>) |
Sets a global handler that intercepts all the the events of the specified type. More... | |
static GString | keyToName (GKeyCode key) |
Converts a key code into a key name and vice-versa. | |
Static Public Attributes | |
static const GKeyCode | EscapeKey = SDLK_ESCAPE |
Keycodes of special keys. More... | |
Mouse event: event when the mouse is pressed, released, dragged or moved.
Corresponding triggers: GTrigger::mousedown, mouseup, mousedrag, mousemove
|
inlineoverridevirtual |
Returns the event casted to the specified event subclass.
Throws an exception that resets the event loop if the event does not derive from this subclass.
Reimplemented from guit::GEvent.
|
inlineoverridevirtual |
Returns the event casted to the specified event subclass.
Returns null if if the event does not derive from this subclass.
Reimplemented from guit::GEvent.
|
inline |
Returns the displacement from last GMouseEvent.
|
inline |
Returns the button that was just pressed or released.
Returns an int that is > 0 for mousedown and mouseup events (see GTrigger) and 0 otherwise. 1 indicates the left mouse button, 2 the right button, 3 the middle button, etc.
|
inline |
Returns the number of mouse clicks on click events.
The returned value should only be used for click events (see GTrigger).
|
inline |
Returns an ORed combination of buttons and modifiers; see GEvent::States.
for on::mousedown events the button that was just pressed is not included in the state.
void guit::GMouseEvent::redirectEvent | ( | Gadget & | to_gadget) |
Redirects the event to this gadget.
Useful when creating gadgets interactively: typically the event is fisrt caught by a drawing panel, a gadget can then be created on this panel and the event can redirected to this gadget as if it received the event. This allows resizing or moving the gadget interactively it it has a GDragSize or a GDragPos prop.
|
inherited |
Returns where this event occured.
|
inherited |
Returns the checked child of a box that enforces exclusive selection.
Returns null if N/A, and the same value as GChoiceBox::chosen() otherwise.
|
inlineinherited |
Returns the input channel.
Return 0 for system events, a value > 0 for other input channels (see GChannel).
|
inlineinherited |
Returns the timestamp.
The timestamp is only defined for mouse/finger/key events.
|
inlineinherited |
Changes/returns the event tag.
Can be useful when redirecting events (see GMouseEvent::redirectEvent) so that the gadget that redirects the event can pass data to the final receiver.
|
staticinherited |
Sets a global handler that intercepts all the the events of the specified type.
Events will then processed normally if the handler returns true, and ignored otherwise. Only one handler can be set for a given event type. Passing nullptr removes the corresponding handler.
|
staticinherited |
Converts a mouse button number into an event state.
mouse_button = 1 returns GEventState::Button1 (left button), 2 returns Button 2 (right button), 3 returns Button3 (middle button), etc.
|
staticinherited |
Converts a combination of modifier names to ORed modifier states.
Valid modifier names are: ctrl, shift, meta/cmd, alt, altgr, caps, num. They can be combined by adding a - or a + between them, e.g. ctrl-shift
|
staticinherited |
Keycodes of special keys.
GKeyEvent has a key() method that returns the keycode.