SDL::Event.3pm

Langue: en

Version: 2010-05-06 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

SDL::Event - a SDL perl extension

SYNOPSIS

  use SDL::Event;
  my $event = new SDL::Event;             # create a new event
  while ($event->wait()) {
         my $type = $event->type();      # get event type
         # ... handle event
         exit if $type == SDL_QUIT;
  }
 
 

DESCRIPTION

"SDL::Event" offers an object-oriented approach to SDL events. By creating an instance of SDL::Event via new() you can wait for events, and then determine the type of the event and take an appropriate action.

EXAMPLE

Here is an example of a simple event handler loop routine. See also SDL::App::loop.
        sub loop {
                my ($self,$href) = @_;
                my $event = new SDL::Event;
                while ( $event->wait() ) {
                        # ... insert here your event handling like:
                        if ( ref($$href{$event->type()}) eq "CODE" ) {
                                &{$$href{$event->type()}}($event);
                                $self->sync();
                        }
                }
        }
 
 

METHODS

new()

Create a new event object.

type()

Returns the type of the event, see list of exported symbols for which are available.

pump()

poll()

wait()

Waits for an event end returns then. Always returns true.

set( type, state )

Set the state for all events of the given event's type

set_unicode( toggle )

Toggle unicode on the event.

set_key_repeat( delay, interval)

Sets the delay and intervall of the key repeat rate (e.g. when a user holds down a key on the keyboard).

active_gain()

active_state()

key_state()

key_sym()

key_name()

key_mod()

key_unicode()

key_scancode()

motion_state()

motion_x()

Returns the motion of the mouse in X direction as an absolute value.

motion_y()

Returns the motion of the mouse in Y direction as an absolute value.

motion_xrel()

Returns the motion of the mouse in X direction as a relative value.

motion_yrel()

Returns the motion of the mouse in Y direction as a relative value.

button_state()

Returns the state of the mouse buttons.

button_x()

button_y()

button()

AUTHOR

David J. Goehrig Documentation by Tels <http://bloodgate.com/>

SEE ALSO

perl SDL::App