Class: Ray::Event
- Inherits:
-
Object
- Object
- Ray::Event
- Defined in:
- lib/ray/event.rb,
ext/event.c
Constant Summary collapse
- TypeNone =
No event
INT2FIX(SAY_EVENT_NONE)
- TypeQuit =
User trying to exit
INT2FIX(SAY_EVENT_QUIT)
- TypeResize =
The window was resized
INT2FIX(SAY_EVENT_RESIZE)
- TypeMouseMotion =
Mouse moved
INT2FIX(SAY_EVENT_MOUSE_MOTION)
- TypeWheelMotion =
Mouse wheel moved
INT2FIX(SAY_EVENT_WHEEL_MOTION)
- TypeButtonPress =
Mouse button pressed
INT2FIX(SAY_EVENT_BUTTON_PRESS)
- TypeButtonRelease =
Mouse button released
INT2FIX(SAY_EVENT_BUTTON_RELEASE)
- TypeFocusLoss =
Focus lost
INT2FIX(SAY_EVENT_FOCUS_LOSS)
- TypeFocusGain =
Focus gained
INT2FIX(SAY_EVENT_FOCUS_GAIN)
- TypeMouseLeft =
Mouse left
INT2FIX(SAY_EVENT_MOUSE_LEFT)
- TypeMouseEntered =
Mouse entered
INT2FIX(SAY_EVENT_MOUSE_ENTERED)
- TypeTextEntered =
Text entered
INT2FIX(SAY_EVENT_TEXT_ENTERED)
- TypeKeyPress =
A key was pressed
INT2FIX(SAY_EVENT_KEY_PRESS)
- TypeKeyRelease =
A key was released
INT2FIX(SAY_EVENT_KEY_RELEASE)
- ButtonUnknown =
A button was pressed, but Ray does not know what it corresponds to
INT2FIX(SAY_BUTTON_UNKNOWN)
- ButtonLeft =
INT2FIX(SAY_BUTTON_LEFT)
- ButtonRight =
INT2FIX(SAY_BUTTON_RIGHT)
- ButtonMiddle =
INT2FIX(SAY_BUTTON_MIDDLE)
- KeyUnknown =
Any key Ray doesn’t know about
INT2FIX(SAY_KEY_UNKNOWN)
- KeyA =
INT2FIX(SAY_KEY_A)
- KeyB =
INT2FIX(SAY_KEY_B)
- KeyC =
INT2FIX(SAY_KEY_C)
- KeyD =
INT2FIX(SAY_KEY_D)
- KeyE =
INT2FIX(SAY_KEY_E)
- K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_KEY_KP_5)
- KeyKp6 =
INT2FIX(SAY_KEY_KP_6)
- KeyKp7 =
INT2FIX(SAY_KEY_KP_7)
- KeyKp8 =
INT2FIX(SAY_KEY_KP_8)
- KeyKp9 =
INT2FIX(SAY_KEY_KP_9)
- KeyEscape =
INT2FIX(SAY_KEY_ESCAPE)
- KeyBackspace =
INT2FIX(SAY_KEY_BACKSPACE)
- KeyTab =
INT2FIX(SAY_KEY_TAB)
- KeyReturn =
INT2FIX(SAY_KEY_RETURN)
- KeyPageUp =
INT2FIX(SAY_KEY_PAGE_UP)
- KeyPageDown =
INT2FIX(SAY_KEY_PAGE_DOWN)
- KeyEnd =
INT2FIX(SAY_KEY_END)
- KeyHome =
INT2FIX(SAY_KEY_HOME)
- KeyInsert =
INT2FIX(SAY_KEY_INSERT)
- KeyDelete =
INT2FIX(SAY_KEY_DELETE)
- KeyPause =
INT2FIX(SAY_KEY_PAUSE)
- KeyLControl =
INT2FIX(SAY_KEY_LCONTROL)
- KeyLShift =
INT2FIX(SAY_KEY_LSHIFT)
- KeyLMeta =
INT2FIX(SAY_KEY_LMETA)
- KeyLSuper =
INT2FIX(SAY_KEY_LSUPER)
- KeyRControl =
INT2FIX(SAY_KEY_RCONTROL)
- KeyRShift =
INT2FIX(SAY_KEY_RSHIFT)
- KeyRMeta =
INT2FIX(SAY_KEY_RMETA)
- KeyRSuper =
INT2FIX(SAY_KEY_RSUPER)
- KeyMenu =
INT2FIX(SAY_KEY_MENU)
- KeyLbracket =
INT2FIX(SAY_KEY_LBRACKET)
- KeyRbracket =
INT2FIX(SAY_KEY_RBRACKET)
- KeySemicolon =
INT2FIX(SAY_KEY_SEMICOLON)
- KeyComma =
INT2FIX(SAY_KEY_COMMA)
- KeyPeriod =
INT2FIX(SAY_KEY_PERIOD)
- KeyQuote =
INT2FIX(SAY_KEY_QUOTE)
- KeySlash =
INT2FIX(SAY_KEY_SLASH)
- KeyBackslash =
INT2FIX(SAY_KEY_BACKSLASH)
- KeyTilde =
INT2FIX(SAY_KEY_TILDE)
- KeyEqual =
INT2FIX(SAY_KEY_EQUAL)
- KeyMinus =
INT2FIX(SAY_KEY_MINUS)
- KeyPlus =
INT2FIX(SAY_KEY_PLUS)
- KeyAsterisk =
INT2FIX(SAY_KEY_ASTERISK)
- KeySpace =
INT2FIX(SAY_KEY_SPACE)
- KeyLeft =
INT2FIX(SAY_KEY_LEFT)
- KeyRight =
INT2FIX(SAY_KEY_RIGHT)
- KeyUp =
INT2FIX(SAY_KEY_UP)
- KeyDown =
INT2FIX(SAY_KEY_DOWN)
- KeyF1 =
INT2FIX(SAY_KEY_F1)
- KeyF2 =
INT2FIX(SAY_KEY_F2)
- KeyF3 =
INT2FIX(SAY_KEY_F3)
- KeyF4 =
INT2FIX(SAY_KEY_F4)
- KeyF5 =
INT2FIX(SAY_KEY_F5)
- KeyF6 =
INT2FIX(SAY_KEY_F6)
- KeyF7 =
INT2FIX(SAY_KEY_F7)
- KeyF8 =
INT2FIX(SAY_KEY_F8)
- KeyF9 =
INT2FIX(SAY_KEY_F9)
- KeyF10 =
INT2FIX(SAY_KEY_F10)
- KeyF11 =
INT2FIX(SAY_KEY_F11)
- KeyF12 =
INT2FIX(SAY_KEY_F12)
- KeyF13 =
INT2FIX(SAY_KEY_F13)
- KeyF14 =
INT2FIX(SAY_KEY_F14)
- KeyF15 =
INT2FIX(SAY_KEY_F15)
- ModMeta =
Key modifiers
INT2FIX(SAY_MOD_META)
- ModControl =
INT2FIX(SAY_MOD_CONTROL)
- ModShift =
INT2FIX(SAY_MOD_SHIFT)
- ModSuper =
INT2FIX(SAY_MOD_SUPER)
Instance Method Summary collapse
-
#button ⇒ Integer?
The button that was pressed.
-
#key ⇒ Integer?
The code of the key that was pressed.
-
#key_mod ⇒ Integer?
OR’d set of mod flags.
-
#mouse_pos ⇒ Ray::Vector2?
The position of the mouse indicated by the event.
-
#native_key ⇒ Integer?
The system-specific code of the key.
-
#text ⇒ String?
The text entered by the user.
- #text_without_encoding ⇒ Object
-
#type ⇒ Integer
The type of the event.
-
#wheel_delta ⇒ Integer?
How much the wheel moved.
-
#window_size ⇒ Ray::Vector2?
The new size of the window.
Instance Method Details
#button ⇒ Integer?
Returns The button that was pressed.
68 69 70 71 72 73 74 75 76 77 |
# File 'ext/event.c', line 68
static
VALUE ray_event_button(VALUE self) {
say_event *ev = ray_rb2event(self);
if (ev->type == SAY_EVENT_BUTTON_PRESS ||
ev->type == SAY_EVENT_BUTTON_RELEASE)
return INT2FIX(ev->ev.button.button);
return Qnil;
}
|
#key ⇒ Integer?
Returns The code of the key that was pressed.
97 98 99 100 101 102 103 104 105 106 107 |
# File 'ext/event.c', line 97
static
VALUE ray_event_key(VALUE self) {
say_event *ev = ray_rb2event(self);
if (ev->type == SAY_EVENT_KEY_PRESS ||
ev->type == SAY_EVENT_KEY_RELEASE) {
return INT2FIX(ev->ev.key.code);
}
return Qnil;
}
|
#key_mod ⇒ Integer?
Returns OR’d set of mod flags.
129 130 131 132 133 134 135 136 137 138 139 |
# File 'ext/event.c', line 129
static
VALUE ray_event_key_mod(VALUE self) {
say_event *ev = ray_rb2event(self);
if (ev->type == SAY_EVENT_KEY_PRESS ||
ev->type == SAY_EVENT_KEY_RELEASE) {
return INT2FIX(ev->ev.key.mod);
}
return Qnil;
}
|
#mouse_pos ⇒ Ray::Vector2?
Returns The position of the mouse indicated by the event. This is avairable to mouse motions, wheel motions, button presses, and button releases.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'ext/event.c', line 36
static
VALUE ray_event_mouse_pos(VALUE self) {
say_event *ev = ray_rb2event(self);
if (ev->type == SAY_EVENT_MOUSE_MOTION)
return ray_vector2_to_rb(ev->ev.motion.pos);
else if (ev->type == SAY_EVENT_WHEEL_MOTION)
return ray_vector2_to_rb(ev->ev.wheel.pos);
else if (ev->type == SAY_EVENT_BUTTON_PRESS ||
ev->type == SAY_EVENT_BUTTON_RELEASE)
return ray_vector2_to_rb(ev->ev.button.pos);
return Qnil;
}
|
#native_key ⇒ Integer?
Returns The system-specific code of the key. This allows a program to bind an unknown key to a method by remembering this code.
113 114 115 116 117 118 119 120 121 122 123 |
# File 'ext/event.c', line 113
static
VALUE ray_event_native_key(VALUE self) {
say_event *ev = ray_rb2event(self);
if (ev->type == SAY_EVENT_KEY_PRESS ||
ev->type == SAY_EVENT_KEY_RELEASE) {
return INT2FIX(ev->ev.key.native_code);
}
return Qnil;
}
|
#text ⇒ String?
Returns The text entered by the user.
7 8 9 10 11 |
# File 'lib/ray/event.rb', line 7 def text if content = text_without_encoding content.force_encoding(InternalEncoding) end end |
#text_without_encoding ⇒ Object
4 |
# File 'lib/ray/event.rb', line 4 alias text_without_encoding text |
#type ⇒ Integer
Returns The type of the event. See Type* constants.
26 27 28 29 |
# File 'ext/event.c', line 26
static
VALUE ray_event_type(VALUE self) {
return INT2FIX(ray_rb2event(self)->type);
}
|
#wheel_delta ⇒ Integer?
Returns How much the wheel moved. a positive number means it moved up.
55 56 57 58 59 60 61 62 63 |
# File 'ext/event.c', line 55
static
VALUE ray_event_wheel_delta(VALUE self) {
say_event *ev = ray_rb2event(self);
if (ev->type == SAY_EVENT_WHEEL_MOTION)
return INT2FIX(ev->ev.wheel.delta);
return Qnil;
}
|
#window_size ⇒ Ray::Vector2?
Returns The new size of the window.
142 143 144 145 146 147 148 149 150 |
# File 'ext/event.c', line 142
static
VALUE ray_event_window_size(VALUE self) {
say_event *ev = ray_rb2event(self);
if (ev->type == SAY_EVENT_RESIZE)
return ray_vector2_to_rb(ev->ev.resize.size);
return Qnil;
}
|