uodate
[sdlgit/SDL-Site.git] / pages / blog-0020.html-inc
CommitLineData
ec946b6b 1<div class="blog">
2<h1 id="NAME">
65a97314 3Hello Mouse? An Example of the New Event Code
ec946b6b 4</h1>
5<div class="CONTENT">
65a97314 6<div style="text-align: right;"><i>Any code that is not marketed is dead code <br />
7--mst</i><br />
ca0a3441 8</div><br />
65a97314 9You need the new code from the <b> <a href="http://http://github.com/kthakore/SDL_Perl/tree/redesign">redesign branch</a></b> to use this . <br />
f060e594 10<br />
65a97314 11<pre class="fake-gist" id="fake-gist-231987">#!/usr/bin/env perl
12
13use SDL;
14use SDL::Events;
15use SDL::Event;
16use SDL::Video;
17
18SDL::init(SDL_INIT_VIDEO);
19
20my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE );
21my $event = SDL::Event-&gt;new();
22
23while(1)
24{
25 SDL::Events::pump_events();
26
27 if(SDL::Events::poll_event($event) &amp;&amp; $event-&gt;type == SDL_ACTIVEEVENT)
28 {
29 print "Hello Mouse!!!\n" if ($event-&gt;active_gain &amp;&amp; ($event-&gt;active_state == SDL_APPMOUSEFOCUS) );
30 print "Bye Mouse!!!\n" if (!$event-&gt;active_gain &amp;&amp; ($event-&gt;active_state == SDL_APPMOUSEFOCUS) );
31 }
32
33 exit if($event-&gt;type == SDL_QUIT);
34}</pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3102167581424744259-4268622242266513664?l=yapgh.blogspot.com' alt='' /></div>
35<p><a href="http://feedads.g.doubleclick.net/~a/VcCMh0XKi92JWmYoQnOB3cQLHtY/0/da"><img src="http://feedads.g.doubleclick.net/~a/VcCMh0XKi92JWmYoQnOB3cQLHtY/0/di" border="0" ismap="true"></img></a><br/>
36<a href="http://feedads.g.doubleclick.net/~a/VcCMh0XKi92JWmYoQnOB3cQLHtY/1/da"><img src="http://feedads.g.doubleclick.net/~a/VcCMh0XKi92JWmYoQnOB3cQLHtY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/YetAnotherPerlGameHackeryapgh/~4/xhzWiodiKJI" height="1" width="1"/></div></div>