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 @@

Index

-
@@ -86,19 +89,24 @@

SDL::Event - General event structure

+

CATEGORY

+
+

Core, Events, Structure

+ +

SYNOPSIS

Top

-
 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 event type.

Available type constants:

Event types are grouped by masks. SDL_EVENTMASK($type) will return the proper mask for the given type.

@@ -255,7 +263,7 @@ and when a key is pressed (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).

key_state

@@ -295,7 +303,7 @@ This field is very useful when you are checking for certain key presses, like so

key_unicode

-

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).

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).

motion_x, motion_y

@@ -342,9 +350,9 @@ This is currently only implemented on Windows and Linux/Unix-alikes.

Mouse button events

-

When a mouse button press or release 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 button_button, the position of the mouse -when this event occured is stored in the button_x and the button_y fields. Like SDL_KeyboardEvent, +

When a mouse button press or release 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 button_button. The position of the mouse +when this event occured is stored in the button_x and the button_y fields. Like a keyboard event, information on whether the event was a press or a release event is stored in both the button_type and button_state fields, but this should be obvious.

Mouse wheel events are reported as buttons 4 (up) and 5 (down). Two events are generated i.e. you get @@ -476,16 +484,34 @@ polled (last cycle of the event loop) and it is stored in jball_xrel

-

resize_x, resize_y

-
+

resize_w, resize_h

+
+

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.

Window expose events

+

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.

System window manager events

+

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);
+
+
+

See http://www.libsdl.org/cgi/docwiki.cgi/SDL_SysWMEvent

syswm_msg

@@ -494,28 +520,47 @@ polled (last cycle of the event loop) and it is stored in jball_xrel

User defined events

+

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_code

+

User defined event code (integer).

user_data1, user_data2

+

User defined data.

Quit event

-

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

-

AUTHOR

Top

-
+

AUTHORS

Top

+

SEE ALSO

Top

-

perl

+

perl +

\ No newline at end of file