SDL::Event - a SDL perl extension


SDL_Perl documentation  | view source Contained in the SDL_Perl distribution.

Index


NAME

Top

SDL::Event - a SDL perl extension

SYNOPSIS

Top

 use SDL::Event;
 my $event = new SDL::Event;             # create a new event
 $event->pump(); 		   	 # pump all events from SDL Event Queue
 $event->poll();			 # Get the top one from the queue
 while ($event->wait()) {
 	my $type = $event->type();      # get event type
 	# ... handle event
 	exit if $type == SDL_QUIT;
 }

DESCRIPTION

Top

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

Top

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

Top

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

Top

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

SEE ALSO

Top

perl SDL::App


SDL_Perl documentation  | view source Contained in the SDL_Perl distribution.