Dear all!
I'm still working on this kind of button-like widget and I want to implement
the behaviour when hovering over the button.
Unfortunately, the button_state does not work as I expected (maybe I
expected it wrong).
When I click somewhere, continue to hold down the mouse button (so there is
no SDL_MOUSEBUTTONUP event) and move the mouse, shouldn't
$event->button_state return SDL_PRESSED (which is 1)?
Because, using the script attached, I always get SDL_RELEASED (0).
The single case where I get SDL_PRESSED is when I check it on
SDL_MOUSEBUTTONDOWN.
So, is this behaviour intended?
Or, to ask it in another way: do I have to keep track of the
SDL_MOUSEBUTTONUP event myself in order to determine if the user still holds
down the mouse button?
Kind regards,
Alex
#!perl
use strict;
use warnings;
use SDL;
use SDLx::App;
use SDL::Event; # for the event object itself
use SDL::Events; # functions for event queue handling
my $app = SDLx::App->new(
title => 'text wrap',
exit_on_quit => 1,
init => SDL_INIT_VIDEO
);
$app->add_show_handler( \&render );
$app->add_event_handler( \&handle_events );
$app->run();
exit(0);
sub handle_events {
my $event = shift;
my $controller = shift;
if( $event->type == SDL_MOUSEMOTION ) {
printf "Button state: [%s]\n",$event->button_state;
}
return;
}
sub render {
my ($delta, $app) = @_;
$app->update();
return;
} # /render