It seems that SDL/Cursor.pm needs a "use SDL;" in it in order to pull
the definition of 'verify' into the scope.  Otherwise, the ->new
function fails.

Also, I find the fact that you need to create a cursor object in order
to hide or show the cursor to be counter-intuitive.  SDL::Cursor::show
should be callable as function, not just as a method.  Alternatively,
the new method could be changed to not require making a new cursor just
to access these functions (it could just return a blessed reference,
rather than actually calling SDL::NewCursor).

Also, and the SDL docs are confusing in this regard, the argument to
show is labeled "$toggle", which implies there is some state kept.  I
think a toggle_visiblity function would be nice, to make this obvious.

See the attached patch which implements these changes, and fixes some
minor issues with the POD section.

-- 
Andy <[EMAIL PROTECTED]>
--- /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi/SDL/Cursor.pm	2005-11-25 21:59:20.000000000 -0600
+++ ./lib/SDL/Cursor.pm	2005-11-25 22:19:15.000000000 -0600
@@ -6,6 +6,8 @@
 package SDL::Cursor;
 use strict;
 
+use SDL;
+
 sub new {
 	my $proto = shift;
 	my $class = ref($proto) || $proto;
@@ -39,10 +41,17 @@
 }
 
 sub show ($;$) {
-	my ($self,$toggle) = @_;
+    my($self, $toggle) = @_;
+    $toggle = $self unless (ref($self));
 	SDL::ShowCursor($toggle);
 }
 
+sub toggle_visiblity {
+    my $c = SDL::ShowCursor(SDL_QUERY);
+    $c = !$c;
+    SDL::ShowCursor($c);
+}
+
 1;
 
 __END__;
@@ -79,27 +88,30 @@
 
 Set the position of the cursor at the <C>$x</C>, <C>$y</C> coordinates in the application window.
 
-=head2 use()
+=head2 use( )
 
 Set the cursor as the active cursor.
 
-=head2 get()
+=head2 get( )
 
 When used statically <C>SDL::Cursor::get()</C>, it will return the instance of the current cursor in use. Called as a method, it will return itself.
 
 This method can be useful if you are dealing with several cursors.
 
-=head2 show($toggle)
+=head2 show($mode)
+
+Set the visibility of the cursor. <C>$mode</C> can be either SDL_ENABLE (or true) to make the cursor visible, SDL_DISABLE (or false) to hide the cursor when it is in the application window, or SDL_QUERY to return the current state.
+
+=head2 toggle_visbility( )
 
-Set the visibility of the cursor. A false value will make the cursor
-invisible in the Application window. A true value will show it back.
+Toggles the visibility of the cursor, showing it if is hidden and hiding it if is shown.
 
 =head1 AUTHOR
 
-David J. Goehrig
+David J. Goehrig, with minor changes by Andy Bakun.
 
 =head1 SEE ALSO
 
-L<perl> L<SDL::Surface>
+L<perl> L<SDL::Surface> L<SDL::App>
 
 =cut	

Reply via email to