Wiki Page Content

Differences between revisions 9 and 10
Revision 9 as of 2013-08-08 21:52:12
Size: 1258
Editor: RyanGordon
Comment: Edited
Revision 10 as of 2013-08-08 21:55:08
Size: 1377
Editor: RyanGordon
Comment: Corrected event type information
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
||Uint32||'''type'''||SDL_USEREVENT through SDL_NUMEVENTS-1|| ||Uint32||'''type'''||Value obtained from [[SDL_RegisterEvents]]()||
Line 18: Line 18:
SDL_Event event;
SDL_zero(event);
event.type = SDL_USEREVENT;
event.user.code = my_event_code;
event.user.data1 = significant_data;
event.user.data2 = 0;
SDL_PushEvent(&event);
Uint32 myEventType = SDL_RegisterEvents(1);
if (myEventType != -1) {
    SDL_Event event;
    
SDL_zero(event);
    event.type = myEventType;
    
event.user.code = my_event_code;
    event.user.data1 = significant_data;
    event.user.data2 = 0;
    SDL_PushEvent(&event);
}
Line 28: Line 31:
[[SDL_UserEvent]] is in the '''user''' member of the [[SDL_Event]] union. This event is unique; it is never created by SDL but only by the application. The event can be pushed onto the event queue using [[SDL_PushEvent]](). The contents of the structure members are completely up to the programmer; the only requirement is that '''type''' is a value from SDL_USEREVENT to SDL_NUMEVENTS-1 (inclusive). [[SDL_UserEvent]] is in the '''user''' member of the [[SDL_Event]] union. This event is unique; it is never created by SDL but only by the application. The event can be pushed onto the event queue using [[SDL_PushEvent]](). The contents of the structure members are completely up to the programmer; the only requirement is that '''type''' is a value obtained from [[SDL_RegisterEvents]]().
Line 34: Line 37:
 .[[SDL_PushEvent]] *  .[[SDL_RegisterEvent]]
.[[SDL_PushEvent]]

SDL_UserEvent

A structure that contains an application-defined event type.

Data Fields

Uint32

type

Value obtained from SDL_RegisterEvents()

Uint32

windowID

the associated window, if any

Sint32

code

user defined event code

void*

data1

user defined data pointer

void*

data2

user defined data pointer

Code Examples

Uint32 myEventType = SDL_RegisterEvents(1);
if (myEventType != -1) {
    SDL_Event event;
    SDL_zero(event);
    event.type = myEventType;
    event.user.code = my_event_code;
    event.user.data1 = significant_data;
    event.user.data2 = 0;
    SDL_PushEvent(&event);
}

Remarks

SDL_UserEvent is in the user member of the SDL_Event union. This event is unique; it is never created by SDL but only by the application. The event can be pushed onto the event queue using SDL_PushEvent(). The contents of the structure members are completely up to the programmer; the only requirement is that type is a value obtained from SDL_RegisterEvents().


CategoryStruct, CategoryEvents

None: SDL_UserEvent (last edited 2015-10-29 21:58:30 by PhilippWiesemann)

Feedback
Please include your contact information if you'd like to receive a reply.
Submit