.TH "SDLmm::EventHandler" 3 "16 Jul 2001" "SDLmm" \" -*- nroff -*- .ad l .nh .SH NAME SDLmm::EventHandler \- The base class used for custom \fBEvent\fP handlers. .SH SYNOPSIS .br .PP \fC#include \fP .PP .SS "Public Methods" .in +1c .ti -1c .RI "virtual bool \fBHandleEvent\fP (SDL_Event &event)" .br .RI "\fICatch-all event handler.\fP" .in -1c .PP .RI "\fBKeyboard Events\fP" .br .in +1c .in +1c .ti -1c .RI "virtual bool \fBHandleKeyboardEvent\fP (SDL_keysym &keysym, bool pressed)" .br .RI "\fIKeyboard event callback.\fP" .ti -1c .RI "virtual bool \fBHandleKeyPressEvent\fP (SDL_keysym &keysym)" .br .RI "\fIKeyboard press event callback.\fP" .ti -1c .RI "virtual bool \fBHandleKeyReleaseEvent\fP (SDL_keysym &keysym)" .br .RI "\fIKeyboard release event callback.\fP" .in -1c .in -1c .PP .RI "\fBMouse Events\fP" .br .in +1c .in +1c .ti -1c .RI "virtual bool \fBHandleMouseMotionEvent\fP (Uint8 state, Uint16 x, Uint16 y, Sint16 xrel, Sint16 yrel)" .br .RI "\fIMouse motion event callback.\fP" .ti -1c .RI "virtual bool \fBHandleMouseButtonEvent\fP (Uint8 button, Uint16 x, Uint16 y, bool pressed)" .br .RI "\fIMouse button event callback.\fP" .ti -1c .RI "virtual bool \fBHandleMouseButtonPressEvent\fP (Uint8 button, Uint16 x, Uint16 y)" .br .RI "\fIMouse button press event callback.\fP" .ti -1c .RI "virtual bool \fBHandleMouseButtonReleaseEvent\fP (Uint8 button, Uint16 x, Uint16 y)" .br .RI "\fIMouse button release event callback.\fP" .in -1c .in -1c .PP .RI "\fBJoystick Events\fP" .br .in +1c .in +1c .ti -1c .RI "virtual bool \fBHandleJoyAxisEvent\fP (Uint8 joystick, Uint8 axis, Sint16 value)" .br .RI "\fI\fBJoystick\fP axis motion event callback.\fP" .ti -1c .RI "virtual bool \fBHandleJoyButtonEvent\fP (Uint8 joystick, Uint8 button, bool pressed)" .br .RI "\fI\fBJoystick\fP button event callback.\fP" .ti -1c .RI "virtual bool \fBHandleJoyButtonPressEvent\fP (Uint8 joystick, Uint8 button)" .br .RI "\fI\fBJoystick\fP button press event callback.\fP" .ti -1c .RI "virtual bool \fBHandleJoyButtonReleaseEvent\fP (Uint8 joystick, Uint8 button)" .br .RI "\fI\fBJoystick\fP button release event callback.\fP" .ti -1c .RI "virtual bool \fBHandleJoyHatEvent\fP (Uint8 joystick, Uint8 hat, Uint8 value)" .br .RI "\fI\fBJoystick\fP hat position change event callback.\fP" .ti -1c .RI "virtual bool \fBHandleJoyBallEvent\fP (Uint8 joystick, Uint8 ball, Sint16 xrel, Sint16 yrel)" .br .RI "\fI\fBJoystick\fP trackball motion event callback.\fP" .in -1c .in -1c .PP .RI "\fBWindow / Display Events\fP" .br .in +1c .in +1c .ti -1c .RI "virtual bool \fBHandleActiveEvent\fP (bool gain, Uint8 state)" .br .RI "\fIApplication visibility event callback.\fP" .ti -1c .RI "virtual bool \fBHandleResizeEvent\fP (int w, int h)" .br .RI "\fIWindow resize event callback.\fP" .ti -1c .RI "virtual bool \fBHandleSysWMEvent\fP ()" .br .RI "\fIPlatform-dependent window manager event callback.\fP" .in -1c .in -1c .PP .RI "\fBOther Events\fP" .br .in +1c .in +1c .ti -1c .RI "virtual bool \fBHandleUserEvent\fP (Uint8 type, int code, void *data1, void *data2)" .br .ti -1c .RI "virtual bool \fBHandleQuitEvent\fP ()" .br .RI "\fIQuit requested event callback.\fP" .in -1c .in -1c .SH "DETAILED DESCRIPTION" .PP The base class used for custom \fBEvent\fP handlers. .PP The event handling in \fBSDLmm\fP is rather different to that of SDL in that it uses classes derived from the \fBEventHandler\fP. This allows for clean, type-safe code much closer to the spirit of C++ than the use of a union with a type field. To handle one or more events, you simply build a class derived from this, reimplementing the only functions for the events you need to handle. .PP \fBSee also: \fP .in +1c \fBEvent::HandleEvents\fP() .PP .SH "MEMBER FUNCTION DOCUMENTATION" .PP .SS "bool SDLmm::EventHandler::HandleActiveEvent (bool gain, Uint8 state)\fC [inline, virtual]\fP" .PP Application visibility event callback. .PP This callback is called when an event of type SDL_ACTIVEEVENT is reported. .PP When the mouse leaves or enters the window area a SDL_APPMOUSEFOCUS type activation event occurs, if the mouse entered the window then \fIgain\fP will be true, otherwise \fIgain\fP will be false. A SDL_APPINPUTFOCUS type activation event occurs when the application loses or gains keyboard focus. This usually occurs when another application is made active. Finally, a SDL_APPACTIVE \fItype\fP event occurs when the application is either minimised/iconified (\fIgain=false)\fP or restored. .PP \fBParameters: \fP .in +1c .TP \fB\fIgain\fP\fP false if the event is a loss or true if it's a gain .TP \fB\fIstate\fP\fP SDL_APPMOUSEFOCUS if mouse focus was gained or lost, SDL_APPINPUTFOCUS if input focus was gained or lost, or SDL_APPACTIVE if the application was iconified (gain=false) or restored (gain=true) .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleEvent (SDL_Event & event)\fC [inline, virtual]\fP" .PP Catch-all event handler. .PP This method is called if none of the event specific callbacks handled event (i.e they returned false). .PP \fBNote: \fP .in +1c It's both easier and more efficient to use the event-specific callbacks, so unless you really want to do all the work yourself, you want to use those. .PP \fBParameters: \fP .in +1c .TP \fB\fIevent\fP\fP the current event .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not .SS "bool SDLmm::EventHandler::HandleJoyAxisEvent (Uint8 joystick, Uint8 axis, Sint16 value)\fC [inline, virtual]\fP" .PP \fBJoystick\fP axis motion event callback. .PP This is used when an event of type SDL_JOYAXISMOTION is reported. .PP A SDL_JOYAXISMOTION event occurs when ever a user moves an axis on the joystick. .PP \fBParameters: \fP .in +1c .TP \fB\fIjoystick\fP\fP the index of the joystick that reported the event .TP \fB\fIaxis\fP\fP the index of the axis (for a more detailed explaination see the \fBJoystick\fP section of the SDL manual). .PP \fBams value is the current position of the axis.\fP .in +1c .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleJoyBallEvent (Uint8 joystick, Uint8 ball, Sint16 xrel, Sint16 yrel)\fC [inline, virtual]\fP" .PP \fBJoystick\fP trackball motion event callback. .PP Thyis is used when an event of type SDL_JOYBALLMOTION is reported. .PP A SDL_JOYBALLMOTION event occurs when a user moves a trackball on the joystick. The field \fIjoystick\fP is the index of the joystick that reported the event and \fIball\fP is the index of the trackball (for a more detailed explaination see the \fBJoystick\fP section in the SDL documentation). Trackballs only return relative motion, this is the change in position on the ball since it was last polled (last cycle of the event loop) and it is stored in \fIxrel\fP and \fIyrel\fP. .PP \fBParameters: \fP .in +1c .TP \fB\fIjoystick\fP\fP joystick device index .TP \fB\fIball\fP\fP joystick trackbal index .TP \fB\fIxrel, yrel\fP\fP relative motion in the x/y directions .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleJoyButtonEvent (Uint8 joystick, Uint8 button, bool pressed)\fC [inline, virtual]\fP" .PP \fBJoystick\fP button event callback. .PP This is used when an event of type SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP is reported. .PP These events occurs when ever a user presses or releases a button on a joystick. .PP \fBNote: \fP .in +1c This function is only called if the default \fBHandleJoyButtonPressEvent\fP() and / or \fBHandleJoyButtonReleaseEvent\fP() methods are used. .PP \fBParameters: \fP .in +1c .TP \fB\fIjoystick\fP\fP the index of the joystick that reported the event .TP \fB\fIbutton\fP\fP the index of the pressed button (for a more detailed explaination see the \fBJoystick\fP section of the SDL manual). .TP \fB\fIpressed\fP\fP true for SDL_JOYBUTTONDOWN, false for SDL_JOYBUTTONUP. .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleJoyButtonPressEvent (Uint8 joystick, Uint8 button)\fC [inline, virtual]\fP" .PP \fBJoystick\fP button press event callback. .PP This is used when an event of type SDL_JOYBUTTONDOWN is reported. .PP A SDL_JOYBUTTONDOWN event occurs when ever a user presses a button on a joystick. .PP \fBNote: \fP .in +1c The default declaration of this method calls the \fBHandleJoyButtonEvent\fP() method. If you want to handle both button presses and releases in the same method, just redefine \fBHandleJoyButtonEvent\fP(). .PP \fBParameters: \fP .in +1c .TP \fB\fIjoystick\fP\fP the index of the joystick that reported the event .TP \fB\fIbutton\fP\fP the index of the pressed button (for a more detailed explaination see the \fBJoystick\fP section of the SDL manual). .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleJoyButtonReleaseEvent (Uint8 joystick, Uint8 button)\fC [inline, virtual]\fP" .PP \fBJoystick\fP button release event callback. .PP This is used when an event of type SDL_JOYBUTTONUP is reported. .PP A SDL_JOYBUTTONUP event occurs when ever a user releases a button on a joystick. .PP \fBNote: \fP .in +1c The default declaration of this method calls the \fBHandleJoyButtonEvent\fP() method. If you want to handle both button presses and releases in the same method, just redefine \fBHandleJoyButtonEvent\fP(). .PP \fBParameters: \fP .in +1c .TP \fB\fIjoystick\fP\fP the index of the joystick that reported the event .TP \fB\fIbutton\fP\fP the index of the released button (for a more detailed explaination see the \fBJoystick\fP section of the SDL manual). .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleJoyHatEvent (Uint8 joystick, Uint8 hat, Uint8 value)\fC [inline, virtual]\fP" .PP \fBJoystick\fP hat position change event callback. .PP This is used when an event of type SDL_JOYHATMOTION is reported. .PP A SDL_JOYHATMOTION event occurs when ever a user moves a hat on the joystick. The field \fIjoystick\fP is the index of the joystick that reported the event and \fIhat\fP is the index of the hat (for a more detailed exlaination see the \fBJoystick\fP section in the SDL documentation). \fIvalue\fP is the current position of the hat. It is a logically OR'd combination of the following values (whose meanings should be pretty obvious): .TP SDL_HAT_CENTERED .TP SDL_HAT_UP .TP SDL_HAT_RIGHT .TP SDL_HAT_DOWN .TP SDL_HAT_LEFT .PP The following defines are also provided: .PP .TP SDL_HAT_RIGHTUP .TP SDL_HAT_RIGHTDOWN .TP SDL_HAT_LEFTUP .TP SDL_HAT_LEFTDOWN .PP \fBParameters: \fP .in +1c .TP \fB\fIjoystick\fP\fP joystick device index .TP \fB\fIhat\fP\fP joystick hat index .TP \fB\fIvalue\fP\fP hat position .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleKeyPressEvent (SDL_keysym & keysym)\fC [inline, virtual]\fP" .PP Keyboard press event callback. .PP This callback is used when an event of type SDL_KEYDOWN is reported. A keyboard press event occurs when a key is pressed. .PP \fBNote: \fP .in +1c Repeating SDL_KEYDOWN events will occur if key repeat is enabled (see EnableKeyRepeat()). .in -1c .in +1c The default declaration of this method calls the \fBHandleKeyboardEvent\fP() method. If you want to handle both key presses and key releases in the same method, just redefine \fBHandleKeyboardEvent\fP(). .PP \fBParameters: \fP .in +1c .TP \fB\fIkeysym\fP\fP information about the pressed key .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleKeyReleaseEvent (SDL_keysym & keysym)\fC [inline, virtual]\fP" .PP Keyboard release event callback. .PP This callback is used when an event of type SDL_KEYUP is reported. A keyboard press event occurs when a key is released. .PP \fBParameters: \fP .in +1c .TP \fB\fIkeysym\fP\fP the information about the released key .PP \fBNote: \fP .in +1c The default declaration of this method calls the \fBHandleKeyboardEvent\fP() method. If you want to handle both key presses and releases in the same method, just redefine \fBHandleKeyboardEvent\fP(). .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleKeyboardEvent (SDL_keysym & keysym, bool pressed)\fC [inline, virtual]\fP" .PP Keyboard event callback. .PP This callback is used when an event of type SDL_KEYDOWN or SDL_KEYUP is reported. These occur when keys are pressed or released. .PP \fBNote: \fP .in +1c Repeating SDL_KEYDOWN events will occur if key repeat is enabled (see EnableKeyRepeat()). .in -1c .in +1c This function is only called if the default \fBHandleKeyPressEvent\fP() and / or \fBHandleKeyReleaseEvent\fP() methods are used. .PP \fBParameters: \fP .in +1c .TP \fB\fIkeysym\fP\fP information about the pressed key .TP \fB\fIpressed\fP\fP true for SDL_KEYDOWN, false for SDL_KEYUP .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleMouseButtonEvent (Uint8 button, Uint16 x, Uint16 y, bool pressed)\fC [inline, virtual]\fP" .PP Mouse button event callback. .PP This is used when an event of type SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP is reported. .PP When a mouse button press is detected the number of the button pressed (from 1 to 255, with 1 usually being the left button and 2 the right) is placed into \fIbutton\fP. The position of the mouse when this event occured is stored in \fIx\fP and \fIy\fP. .PP \fBNote: \fP .in +1c This function is only called if the default \fBHandleMouseButtonPressEvent\fP() and / or \fBHandleMouseButtonReleaseEvent\fP() methods are used. .PP \fBParameters: \fP .in +1c .TP \fB\fIbutton\fP\fP the mouse button index .TP \fB\fIx, y\fP\fP the x/y coordinates of the mouse at press time .TP \fB\fIpressed\fP\fP true for SDL_MOUSEBUTTONDOWN, false for SDL_MOUSEBUTTONUP. .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleMouseButtonPressEvent (Uint8 button, Uint16 x, Uint16 y)\fC [inline, virtual]\fP" .PP Mouse button press event callback. .PP This is used when an event of type SDL_MOUSEBUTTONDOWN is reported. .PP When a mouse button press is detected the number of the button pressed (from 1 to 255, with 1 usually being the left button and 2 the right) is placed into \fIbutton\fP. The position of the mouse when this event occured is stored in \fIx\fP and \fIy\fP. .PP \fBNote: \fP .in +1c The default declaration of this method calls the \fBHandleMouseButtonEvent\fP() method. If you want to handle both button presses and releases in the same method, just redefine \fBHandleMouseButtonEvent\fP(). .PP \fBParameters: \fP .in +1c .TP \fB\fIbutton\fP\fP the mouse button index .TP \fB\fIx, y\fP\fP the x/y coordinates of the mouse at press time .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleMouseButtonReleaseEvent (Uint8 button, Uint16 x, Uint16 y)\fC [inline, virtual]\fP" .PP Mouse button release event callback. .PP This is used when an event of type SDL_MOUSEBUTTONUP is reported. .PP When a mouse button release is detected the number of the button release (from 1 to 255, with 1 usually being the left button and 2 the right) is placed into \fIbutton\fP. The position of the mouse when this event occured is stored in \fIx\fP and \fIy\fP. .PP \fBNote: \fP .in +1c The default declaration of this method calls the \fBHandleMouseButtonEvent\fP() method. If you want to handle both button presses and releases in the same method, just redefine \fBHandleMouseButtonEvent\fP(). .PP \fBParameters: \fP .in +1c .TP \fB\fIbutton\fP\fP the mouse button index .TP \fB\fIx, y\fP\fP the x/y coordinates of the mouse at press time .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleMouseMotionEvent (Uint8 state, Uint16 x, Uint16 y, Sint16 xrel, Sint16 yrel)\fC [inline, virtual]\fP" .PP Mouse motion event callback. .PP This is used when an event of type SDL_MOUSEMOTION is reported. .PP Simply put, a SDL_MOUSEMOTION type event occurs when a user moves the mouse within the application window or when SDL_WarpMouse is called. Both the absolute (\fIx\fP and \fIy)\fP and relative (\fIxrel\fP and \fIyrel)\fP coordinates are reported along with the current button states (\fIstate)\fP. The button \fIstate\fP can be interpreted using the SDL_BUTTON macro (see GetMouseState()). .PP If the cursor is hidden (Display::HideCursor()) and the input is grabbed (Display::GrabInput(SDL_GRAB_ON)) then the mouse will give relative motion events even when the cursor reaches the edge of the screen. This is currently only implemented on Windows and Linux/Unix-a-likes. .PP \fBParameters: \fP .in +1c .TP \fB\fIstate\fP\fP the current button state. .TP \fB\fIx, y\fP\fP the absolute x/y coordinates of the mouse pointer .TP \fB\fIxrel, yrel\fP\fP relative motion in the x/y directions .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleQuitEvent ()\fC [inline, virtual]\fP" .PP Quit requested event callback. .PP This is used whan an event of type SDL_QUIT is reported. .PP The SDL_QUIT event is very important. If you filter out or ignore a quit event it is impossible for the user to close the window. On the other hand, if you do accept a quit event, the application window will be closed, and screen updates will still report success, even though the application will no longer be visible. .PP \fBNote: \fP .in +1c The macro SDL_QuitRequested will return non-zero if a quit event is pending. .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleResizeEvent (int w, int h)\fC [inline, virtual]\fP" .PP Window resize event callback. .PP This is used when an event of type SDL_VIDEORESIZE is reported. .PP When SDL_RESIZABLE is passed as a flag to \fBDisplay::SetVideoMode\fP() the user is allowed to resize the applications window. When the window is resized an SDL_VIDEORESIZE is reported, with the new window width and height values stored in \fIw\fP and \fIh\fP, respectively. When an SDL_VIDEORESIZE is recieved the window should be resized to the new dimensions using \fBDisplay::SetVideoMode\fP(); .PP \fBParameters: \fP .in +1c .TP \fB\fIw, h\fP\fP new width and height of the window. .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleSysWMEvent ()\fC [inline, virtual]\fP" .PP Platform-dependent window manager event callback. .PP The system window manager event contains a pointer to system-specific information about unknown window manager events. If you enable this event using \fBEvent::EventState\fP(), it will be generated whenever unhandled events are received from the window manager. This can be used, for example, to implement cut-and-paste in your application. .PP If you want to obtain system-specific information about the window manager, you can fill the version member of a SDL_SysWMinfo structure (details can be found in SDL_syswm.h, which must be included) using the SDL_VERSION() macro found in SDL_version.h, and pass it to the function: .PP .nf int SDL_GetWMInfo(SDL_SysWMinfo *info); .fi .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SS "bool SDLmm::EventHandler::HandleUserEvent (Uint8 type, int code, void * data1, void * data2)\fC [inline, virtual]\fP" .PP This event is unique - it is never created by SDL but only by the user. The event can be pushed onto the event queue using \fBEvent::Push\fP(). The contents of \fIdata1\fP and \fIdata2\fP are completely up to the programmer. The only requirement is that \fItype\fP is a value from SDL_USEREVENT to SDL_NUMEVENTS-1 (inclusive). .PP \fBParameters: \fP .in +1c .TP \fB\fItype\fP\fP SDL_USEREVENT through to SDL_NUMEVENTS-1 .TP \fB\fIcode\fP\fP user defined event code .TP \fB\fIdata1, data2\fP\fP user defined data pointers .PP \fBReturns: \fP .in +1c true if the event was handled, false if it was not. If the event wasn't handled, it will be handed over to the generic \fBHandleEvent\fP() method. .SH "AUTHOR" .PP Generated automatically by Doxygen for SDLmm from the source code.