X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2FSDL-Event.html-inc;h=de04a03c6b8d8c9d400efe062be0a22bf70856cf;hb=0b221bb4fce84647a6cb9d7343de7330fb561c71;hp=3b0a95ba827cae964eccf93a9cd5f73618d048d4;hpb=9be5218664cd05a23d5591d4f2c5acf71986202a;p=sdlgit%2FSDL-Site.git diff --git a/pages/SDL-Event.html-inc b/pages/SDL-Event.html-inc index 3b0a95b..de04a03 100644 --- a/pages/SDL-Event.html-inc +++ b/pages/SDL-Event.html-inc @@ -2,7 +2,10 @@
SDL::Event - General event structure
+Core, Events, Structure
+ +use SDL::Event; # for the event object itself - use SDL::Events qw(pump_events poll_event); # functions for event queue handling +use SDL::Event; # for the event object itself + use SDL::Events; # functions for event queue handling SDL::init(SDL_INIT_VIDEO); my $event = SDL::Event->new(); while(1) { - pump_events(); + SDL::Events::pump_events(); - if(poll_event($event)) + if(SDL::Events::poll_event($event)) { if($event->type == SDL_MOUSEBUTTONDOWN) { @@ -157,22 +165,22 @@ which union member relates to which eventtype
.Available type constants:
Event types are grouped by masks. SDL_EVENTMASK($type)
will return the proper mask for the given type
.
type=SDL_KEYDOWN
or key_state=SDL_
then an SDL_RELEASED
when released and pressed again. For these keys KEYUP
and KEYDOWN
events are therefore
analogous to the state of the caps lock and num lock LEDs rather than the keys themselves.
These special cases are required for compatibility with Sun workstations.
-Note: Repeating SDL_KEYDOWN
events will occur if key repeat is enabled (see SDL_EnableKeyRepeat
).
+Note: Repeating SDL_KEYDOWN
events will occur if key repeat is enabled (see enable_key_repeat).
The unicode
field is only used when UNICODE translation is enabled with SDL_EnableUNICODE.
+
The unicode
field is only used when UNICODE translation is enabled with enable_unicode.
If unicode
is non-zero then this is the UNICODE character corresponding to the keypress.
If the high 9 bits of the character are 0, then this maps to the equivalent ASCII character:
my $char;
@@ -324,7 +332,7 @@ button states (motion_state
).
The button state can be interpreted using the SDL_BUTTON
macro (see SDL_GetMouseState).
The button state can be interpreted using the SDL_BUTTON
macro (see get_mouse_state).
When SDL_RESIZABLE
is passed as a flag to SDL_SetVideoMode
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 the resize structure's resize_w
and resize_h
.
+When an SDL_VIDEORESIZE
is received the window should be resized to the new dimensions using
+SDL_SetVideoMode.
A VIDEOEXPOSE
event is triggered when the screen has been modified outside of the application,
+usually by the window manager and needs to be redrawn.
The system window manager event contains a system-specific information about unknown window manager
+events. If you enable this event using SDL_EventState
, 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.
If you want to obtain system-specific information about the window manager, you can fill in 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:
+int SDL_GetWMInfo(SDL_SysWMinfo *info); + ++
jball_xrel
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 SDL::Events::push_event
. 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)
my $event = SDL::Event->new(); + $event->type ( SDL_USEREVENT + 3 ); + $event->user_code(10); + $event->user_data1('hello event'); + + SDL::Events::push_event($event); + +
User defined event code (integer).
User defined data.
Create a new SDL::Event object.
+As can be seen, the SDL_QuitEvent
structure serves no useful purpose. The event itself, on the other hand,
+is very important. If you filter out or ignore a quit event then it is impossible for the user to close the
+window. On the other hand, if you do accept a quit event then the application window will be closed, and
+screen updates will still report success even though the application will no longer be visible.
Note: The macro SDL_QuitRequested will return non-zero if a quit event is pending