NAME
TCOD::Event - A TCOD wrapper around SDL2 events
SYNOPSIS
use TCOD;
# Block until there is an event
my $iter = TCOD::Event::wait;
# Get each event in turn
while ( my $event = $iter->() ) {
exit if $event->type eq 'QUIT';
}
DESCRIPTION
This class is a thin wrapper around SDL2 events.
METHODS
new
$tcod_event = TCOD::Event->new( $sdl_event );
Wrap an SDL2 event in a TCOD event. You will most likely not have to use this yourself, but it is called internally by the methods below.
FUNCTIONS
wait
$iterator = TCOD::Event::wait( $timeout );
Block until events exist, then return an event iterator.
The value in $timeout
is the maximum number of seconds to wait for the next event. If none is provided, or the value is 0, the code will block for as long as it takes for the next event to be registered.
Returns the same iterator as a call get.
get
$iterator = TCOD::Event::get;
Return a coderef that can be used as an iterator for all pending events. Calling the coderef will return the next avaialble event.
Events are processed as the iterator is consumed. Breaking out of, or discarding the iterator will leave the remaining events on the event queue.
SEE ALSO
COPYRIGHT AND LICENSE
Copyright 2021 José Joaquín Atria
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.