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

- (Integer) button

the mouse button index

Returns:

  • (Integer)

- (Integer) clicks

1 for single click, 2 for double click

This attribute is available after SDL 2.0.2

Returns:

  • (Integer)

- (Boolean) pressed Also known as: pressed?

button is pressed or not

Returns:

  • (Boolean)

- (Integer) which

the mouse index

Returns:

  • (Integer)

- (Integer) window_id

the window id with mouse focus

Returns:

  • (Integer)

- (Integer) x

the x coordinate of the mouse pointer, relative to window

Returns:

  • (Integer)

- (Integer) y

the y coordinate of the mouse pointer, relative to window

Returns:

  • (Integer)

Instance Method Details

- (String) inspect

Returns inspection string

Returns:

  • (String)

    inspection string



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'event.c', line 501

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);
}