Skip to content

Commit 01771ef

Browse files
committed
deal with MacOS bizarrely giving button IDs 5 and 6
1 parent 564e7e5 commit 01771ef

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/PDL/Graphics/OpenGL/Perl/OpenGL.pm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,15 @@ sub _pdl_fake_KeyPress {
286286
my $last_fake_mouse_state;
287287

288288
sub _pdl_fake_button_event {
289-
print "_pdl_fake_button_event: got (@_)\n" if $PDL::Graphics::TriD::verbose;
289+
print "_pdl_fake_button_event: got (@_)\n";# if $PDL::Graphics::TriD::verbose;
290290
$last_fake_mouse_state = $fake_mouse_state;
291+
my $mask = $button_to_mask[$_[0]];
292+
return if !defined $mask; # MacOS sometimes gives button ID 5
291293
if ( $_[1] == 0 ) { # a press
292-
$fake_mouse_state |= $button_to_mask[$_[0]];
294+
$fake_mouse_state |= $mask;
293295
push @fakeXEvents, [ 4, $_[0]+1, @_[2,3], -1, -1, $last_fake_mouse_state ];
294296
} elsif ( $_[1] == 1 ) { # a release
295-
$fake_mouse_state &= ~$button_to_mask[$_[0]];
297+
$fake_mouse_state &= ~$mask;
296298
push @fakeXEvents, [ 5, $_[0]+1 , @_[2,3], -1, -1, $last_fake_mouse_state ];
297299
} else {
298300
die "ERROR: _pdl_fake_button_event got unexpected value!";

0 commit comments

Comments
 (0)