1SDL::Event(3) User Contributed Perl Documentation SDL::Event(3)
2
3
4
6 SDL::Event - a SDL perl extension
7
9 use SDL::Event;
10 my $event = new SDL::Event; # create a new event
11 while ($event->wait()) {
12 my $type = $event->type(); # get event type
13 # ... handle event
14 exit if $type == SDL_QUIT;
15 }
16
18 "SDL::Event" offers an object-oriented approach to SDL events. By
19 creating an instance of SDL::Event via new() you can wait for events,
20 and then determine the type of the event and take an appropriate
21 action.
22
24 Here is an example of a simple event handler loop routine. See also
25 SDL::App::loop.
26
27 sub loop {
28 my ($self,$href) = @_;
29 my $event = new SDL::Event;
30 while ( $event->wait() ) {
31 # ... insert here your event handling like:
32 if ( ref($$href{$event->type()}) eq "CODE" ) {
33 &{$$href{$event->type()}}($event);
34 $self->sync();
35 }
36 }
37 }
38
40 new()
41 Create a new event object.
42
43 type()
44 Returns the type of the event, see list of exported symbols for which
45 are available.
46
47 pump()
48 poll()
49 wait()
50 Waits for an event end returns then. Always returns true.
51
52 set( type, state )
53 Set the state for all events of the given event's type
54
55 set_unicode( toggle )
56 Toggle unicode on the event.
57
58 set_key_repeat( delay, interval)
59 Sets the delay and intervall of the key repeat rate (e.g. when a user
60 holds down a key on the keyboard).
61
62 active_gain()
63 active_state()
64 key_state()
65 key_sym()
66 key_name()
67 key_mod()
68 key_unicode()
69 key_scancode()
70 motion_state()
71 motion_x()
72 Returns the motion of the mouse in X direction as an absolute value.
73
74 motion_y()
75 Returns the motion of the mouse in Y direction as an absolute value.
76
77 motion_xrel()
78 Returns the motion of the mouse in X direction as a relative value.
79
80 motion_yrel()
81 Returns the motion of the mouse in Y direction as a relative value.
82
83 button_state()
84 Returns the state of the mouse buttons.
85
86 button_x()
87 button_y()
88 button()
90 David J. Goehrig Documentation by Tels <http://bloodgate.com/>
91
93 perl SDL::App
94
95
96
97perl v5.12.0 2010-05-06 SDL::Event(3)