Class: SDL2::Event::MouseButton

Inherits:
SDL2::Event show all
Defined in:
event.c,
event.c

Overview

This class represents mouse button events.

You don’t handle the instance of this class directly, but you handle the instances of two subclasses of this subclasses: MouseButtonDown and MouseButtonUp.

Direct Known Subclasses

MouseButtonDown, MouseButtonUp

Instance Attribute Summary collapse

Attributes inherited from SDL2::Event

#timestamp, #type

Instance Method Summary collapse

Methods inherited from SDL2::Event

enable=, enabled?, poll, #window

Instance Attribute Details

#buttonInteger

the mouse button index

Returns:

  • (Integer)

#clicksInteger

1 for single click, 2 for double click

This attribute is available after SDL 2.0.2

Returns:

  • (Integer)

#pressedBoolean Also known as: pressed?

button is pressed or not

Returns:

  • (Boolean)

#whichInteger

the mouse index

Returns:

  • (Integer)

#window_idInteger

the window id with mouse focus

Returns:

  • (Integer)

#xInteger

the x coordinate of the mouse pointer, relative to window

Returns:

  • (Integer)

#yInteger

the y coordinate of the mouse pointer, relative to window

Returns:

  • (Integer)

Instance Method Details

#inspectString

Returns inspection string

Returns:

  • (String)

    inspection string



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'event.c', line 508

static VALUE EvMouseButton_inspect(VALUE self)
{
    SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
    return rb_sprintf("<%s: type=%u timestamp=%u"
                      " window_id=%u which=%u button=%hhu pressed=%s"
#if SDL_VERSION_ATLEAST(2,0,2)
                      " clicks=%hhu"
#endif
                      " x=%d y=%d>",
                      rb_obj_classname(self), ev->common.type, ev->common.timestamp,
                      ev->button.windowID, ev->button.which,
                      ev->button.button, INT2BOOLCSTR(ev->button.state),
#if SDL_VERSION_ATLEAST(2,0,2)
                      ev->button.clicks,
#endif
                      ev->button.x, ev->button.y);
}