NAME

SDL::App::FPS::EventHandler - a event handler class for SDL::App::FPS

SYNOPSIS

my $handler = SDL::App::FPS::EventHandler->new(
	SDL_KEYDOWN,
	SDLK_SPACE,
	sub { my $self = shift; $self->pause(); },
};

my $handler2 = SDL::App::FPS::EventHandler->new(
	SDL_MOUSEBUTTONDOWN,
	LEFTMOUSEBUTTON,
	sub { my $self = shift; $self->time_warp(2,2000); },
};

EXPORTS

Three symbols on request, namely:

LEFTMOUSEBUTTON
RIGHTMOUSEBUTTON
MIDDLEMOUSEBUTTON

DESCRIPTION

This package provides an event handler class.

Event handlers are register to watch out for certain external events like keypresses, mouse movements and so on, and when these happen, call a callback routine.

CALLBACK

Once the event has occured, the callback code (CODE ref) is called with the following parameters:

&{$callback}($self,$handler,$event);

$self is the app the event handler resides in (e.g. the object of type SDL::App::FPS), $handler is the event handler itself, and $event the SDL::Event that caused the handler to be activated.

METHODS

new()
my $handler = SDL::App::FPS::EventHandler->new(
	$type,
	$kind,
	$callback,
	$app
);

Creates a new event handler to watch out for $type events (SDL_KEYDOWN, SDL_MOUSEMOVED, SDL_MOUSEBUTTONDOWN etc) and then for $kind kind of it, like SDLK_SPACE. Mouse movement events ignore the $kind parameter.

$app is the ref to the application the handler resides in and is passed as first argument to the callback function when called.

is_active()
$handler->is_active();

Returns true if the event handler is active, or false for inactive. Inactive event handlers ignore any events that might happen.

activate()

Set the event handler to active. Newly created ones are always active.

deactivate()

Set the event handler to inactive. Newly created ones are always active.

rebind()
$handler->rebind(SDL_KEYUP, SDLK_P);

Set a new type and kind for the handler to watch out for.

id()

Return the handler's unique id.

AUTHORS

(c) 2002, 2003, Tels <http://bloodgate.com/>

SEE ALSO

SDL:App::FPS, SDL::App and SDL.