e65be37dd7211e92b433042690e9c72fb1ba4899
[sdlgit/SDL-Site.git] / pages / blog-0025.html-inc
1 <div class="blog">
2 <h1 id="NAME">
3 Hello Mouse? An Example of the New Event Code
4 </h1>
5 <div class="CONTENT">
6 <div style="text-align: right;"><i>Any code that is not marketed is dead code <br />
7 --mst</i><br />
8 </div><br />
9 You 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 />
10 <br />
11 <pre class="fake-gist" id="fake-gist-231987">#!/usr/bin/env perl
12
13 use SDL;
14 use SDL::Events;
15 use SDL::Event;
16 use SDL::Video; 
17
18 SDL::init(SDL_INIT_VIDEO);
19
20 my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE );
21 my $event   = SDL::Event-&gt;new(); 
22
23 while(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>