Irrlicht 3D Engine
IEventReceiver.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_EVENT_RECEIVER_H_INCLUDED__
6 #define __I_EVENT_RECEIVER_H_INCLUDED__
7 
8 #include "ILogger.h"
9 #include "Keycodes.h"
10 #include "irrString.h"
11 
12 namespace irr
13 {
16  {
18 
23 
25 
31 
33 
36 
38 
46 
48 
51 
53 
66 
69  EGUIET_FORCE_32_BIT = 0x7fffffff
70 
71  };
72 
75  {
78 
81 
84 
87 
90 
93 
96 
100 
104 
108 
112 
116 
120 
124 
127  };
128 
131  {
132  EMBSM_LEFT = 0x01,
133  EMBSM_RIGHT = 0x02,
134  EMBSM_MIDDLE = 0x04,
135 
137  EMBSM_EXTRA1 = 0x08,
138 
140  EMBSM_EXTRA2 = 0x10,
141 
142  EMBSM_FORCE_32_BIT = 0x7fffffff
143  };
144 
145  namespace gui
146  {
147 
148  class IGUIElement;
149 
152  {
154 
157 
159 
161 
163 
165 
167 
169 
171 
174 
177 
180 
183 
185 
187 
189 
191 
194 
197 
200 
203 
206 
209 
212 
215 
218 
221 
224 
227 
230 
233 
238 
241 
244 
247 
250 
254 
257  };
258  } // end namespace gui
259 
260 
262 struct SEvent
263 {
265  struct SGUIEvent
266  {
269 
272 
275 
276  };
277 
279  struct SMouseInput
280  {
283 
286 
288 
290 
292  bool Shift:1;
293 
295  bool Control:1;
296 
301 
303  bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); }
304 
306  bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); }
307 
309  bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); }
310 
313  };
314 
316  struct SKeyInput
317  {
319  wchar_t Char;
320 
323 
325  bool PressedDown:1;
326 
328  bool Shift:1;
329 
331  bool Control:1;
332  };
333 
335 
343  {
344  enum
345  {
347 
348  AXIS_X = 0, // e.g. analog stick 1 left to right
349  AXIS_Y, // e.g. analog stick 1 top to bottom
350  AXIS_Z, // e.g. throttle, or analog 2 stick 2 left to right
351  AXIS_R, // e.g. rudder, or analog 2 stick 2 top to bottom
354  NUMBER_OF_AXES=18 // (please tell Irrlicht maintainers if you absolutely need more axes)
355  };
356 
360 
370 
377 
379 
382 
384  bool IsButtonPressed(u32 button) const
385  {
386  if(button >= (u32)NUMBER_OF_BUTTONS)
387  return false;
388 
389  return (ButtonStates & (1 << button)) ? true : false;
390  }
391  };
392 
393 
395  struct SLogEvent
396  {
398  const c8* Text;
399 
402  };
403 
405  struct SUserEvent
406  {
408  size_t UserData1;
409 
411  size_t UserData2;
412  };
413 
415  union
416  {
423  };
424 
425 };
426 
428 
434 {
435 public:
436 
438  virtual ~IEventReceiver() {}
439 
441 
446  virtual bool OnEvent(const SEvent& event) = 0;
447 };
448 
449 
452 {
454 
458 
461 
464 
466 
469 
471 
473  enum
474  {
477 
480 
483  } PovHat;
484 }; // struct SJoystickInfo
485 
486 
487 } // end namespace irr
488 
489 #endif
490 
A checkbox has changed its check state.
The presence or absence of a hat cannot be determined.
s32 Y
Y position of mouse cursor.
size_t UserData2
Another user specified data as int.
bool isMiddlePressed() const
Is the middle button pressed down?
signed short s16
16 bit signed variable.
Definition: irrTypes.h:52
enum irr::SJoystickInfo::@3 PovHat
An indication of whether the joystick has a POV hat.
u32 Axes
The number of axes that the joystick has, i.e. X, Y, Z, R, U, V.
An event of the graphical user interface.
The mouse cursor changed its position.
core::stringc Name
The name that the joystick uses to identify itself.
A key input event.
A file has been selected in the file dialog.
EKEY_CODE
Definition: Keycodes.h:11
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
Any kind of keyboard event.
EMOUSE_INPUT_EVENT
Enumeration for all mouse input events.
float f32
32 bit floating point variable.
Definition: irrTypes.h:108
gui::IGUIElement * Element
If the event has something to do with another element, it will be held here.
A scrollbar has changed its position.
Right mouse button was left up.
char c8
8 bit character variable.
Definition: irrTypes.h:35
A directory has been selected in the file dialog.
A user event with user data.
EKEY_CODE Key
Key which has been pressed or released.
No real event. Just for convenience to get number of events.
currently only on windows
size_t UserData1
Some user specified data as int.
A mouse input event.
bool isLeftPressed() const
Is the left button pressed down?
A gui element has got the focus.
Everything in the Irrlicht Engine can be found in this namespace.
Definition: aabbox3d.h:12
An item in the listbox was selected, which was already selected.
A new item in a listbox was selected.
A file open dialog has been closed without choosing a file.
gui::EGUI_EVENT_TYPE EventType
Type of GUI Event.
bool isRightPressed() const
Is the right button pressed down?
wchar_t Char
Character corresponding to the key (0, if not a character, value undefined in key releases)
const c8 * Text
Pointer to text which has been logged.
A tree view node was selected. See IGUITreeView::getLastEventNode().
The text in an editbox was changed. This does not include automatic changes in text-breaking.
Very simple string class with some useful features.
Definition: irrString.h:37
u8 Joystick
The ID of the joystick.
unsigned char u8
8 bit unsigned variable.
Definition: irrTypes.h:22
Middle mouse button was left up.
The marked area in an editbox was changed.
A joystick (joypad, gamepad) input event.
virtual ~IEventReceiver()
Destructor.
struct SJoystickEvent JoystickEvent
The value of a spin box has changed.
unsigned short u16
16 bit unsigned variable.
Definition: irrTypes.h:44
ELOG_LEVEL Level
Log level in which the text has been logged.
Interface of an object which can receive events.
'Yes' was clicked on a messagebox
bool Shift
True if shift was also pressed.
Right mouse button was pressed down.
u32 Buttons
The number of buttons that the joystick has.
Information on a joystick, returned from irr::IrrlichtDevice::activateJoysticks()
signed int s32
32 bit signed variable.
Definition: irrTypes.h:70
gui::IGUIElement * Caller
IGUIElement who called the event.
currently only on windows
In an editbox 'ENTER' was pressed.
bool Control
True if ctrl was also pressed.
u8 Joystick
The ID of the joystick which generated this event.
f32 Wheel
mouse wheel delta, often 1.0 or -1.0, but can have other values < 0.f or > 0.f;
The mouse cursor hovered over a gui element.
unsigned int u32
32 bit unsigned variable.
Definition: irrTypes.h:62
'OK' was clicked on a messagebox
EEVENT_TYPE EventType
bool Control
True if ctrl was also pressed.
Left mouse button was pressed down.
A hat is definitely present.
A gui element has lost its focus.
EEVENT_TYPE
Enumeration for all event types there are.
ELOG_LEVEL
Definition: ILogger.h:17
Base class of all GUI elements.
Definition: IGUIElement.h:23
EGUI_EVENT_TYPE
Enumeration for all events which are sendable by the gui system.
A tree view node was collapsed. See IGUITreeView::getLastEventNode().
A tree view node was expanded. See IGUITreeView::getLastEventNode().
The tab was changed in an tab control.
struct SGUIEvent GUIEvent
bool IsButtonPressed(u32 button) const
A helper function to check if a button is pressed.
Any kind of user event.
struct SMouseInput MouseInput
E_MOUSE_BUTTON_STATE_MASK
Masks for mouse button states.
The mouse cursor left the hovered element.
'No' was clicked on a messagebox
A hat is definitely not present.
EMOUSE_INPUT_EVENT Event
Type of mouse event.
bool Shift
True if shift was also pressed.
struct SUserEvent UserEvent
A button was clicked.
virtual bool OnEvent(const SEvent &event)=0
Called if an event happened.
Middle mouse button was pressed down.
The selection in a combo box has been changed.
No real event. Just for convenience to get number of events.
A table has changed.
struct SLogEvent LogEvent
struct SKeyInput KeyInput
A menu item was selected in a (context) menu.
Left mouse button was left up.
Any kind of mouse event.
A tree view node lost selection. See IGUITreeView::getLastEventNode().
'Cancel' was clicked on a messagebox
s16 Axis[NUMBER_OF_AXES]
Any kind of GUI event.
An element would like to close.
s32 X
X position of mouse cursor.
Any kind of log event.
bool PressedDown
If not true, then the key was left up.