use strict; use warnings; use Wx; package MyApp; use base 'Wx::App'; sub OnInit { my $frame = Wx::Frame->new( undef, -1, 'A Clickable Label', ); my $label = Wx::StaticText->new( $frame, -1, "Click here to exit", ); my $sizer = Wx::BoxSizer->new( Wx::wxVERTICAL() ); $frame->SetSizer($sizer); $sizer->Add($label); $sizer->Add( Wx::Button->new( $frame, -1, "Click here to exit $_", ) ) for 1 .. 3; Wx::Event::EVT_MOUSE_EVENTS( $_[0], sub { #~ perl -MWx -le "print for sort keys %Wx::MouseEvent:: " my ( $s, $e ) = @_; #~ LeftIsDown MiddleIsDown RightIsDown my $IsDown = join( '|', grep { my $m = $_ . 'IsDown'; eval { $e->$m; } } qw' Left Middle Right ' ); $IsDown = sprintf 'IsDown< %s >', $IsDown if length $IsDown; #~ AltDown ButtonDown CmdDown ControlDown LeftDown MetaDown MiddleDown RightDown ShiftDown my $Down = join( '|', grep { my $m = $_ . 'Down'; $e->$m; } qw' Alt Button Cmd Control Left Meta Middle Right Shift ' ); $Down = sprintf 'Down< %s >', $Down if length $Down; #~ ButtonDClick LeftDClick MiddleDClick RightDClick my $DClick = join( '|', grep { my $m = $_ . 'DClick'; $e->$m; } qw' Button Left Middle Right ' ); $DClick = sprintf 'DClick< %s >', $DClick if length $DClick; #~ IsButton IsPageScroll my $Is = join( '|', grep { my $m = 'Is' . $_; $e->$m; } qw' Button PageScroll ' ); $Is = sprintf 'Is< %s >', $Is if length $Is; my $Bool = join( '|', grep { my $m = $_; $e->$m; } qw' Button Dragging Entering Leaving Moving ' ); $Bool = sprintf '< %s >', $Bool if length $Bool; #~ GetButton GetLinesPerAction GetLogicalPosition GetPosition GetPositionXY GetWheelDelta GetWheelRotation GetX GetY my $Get = sprintf "Get< %s >", join( '|', map { my $m = 'Get' . $_; sprintf '%s( %s )', $_, $e->$m; } qw' Button LinesPerAction ', #~ LogicalPosition #~ Usage: Wx::MouseEvent::GetLogicalPosition(THIS, dc) #~ Position PositionXY #~ X Y qw' WheelDelta WheelRotation ' ); my $GetEvent = $e->GetEventType; $GetEvent = TypeIntToStr($GetEvent) . "($GetEvent) " . $e->GetEventObject; my $XY = sprintf "%4d,%4d ", $e->GetPositionXY; print $XY, join ' ', grep length, $Is, $IsDown, $DClick, $Down, $Bool, $Get, $GetEvent, "\n"; $e->Skip; return; } ); $frame->Show; } ## end sub OnInit MyApp->new->MainLoop; BEGIN { my %str2con = map { my $dummy; my $con = Wx::constant( $_, 0, $dummy ); $_ => $con; } grep /^wxEVT_/, keys %Wx::; my %con2str = reverse %str2con; sub TypeIntToStr { $con2str{ +shift } ||'' } } ## end BEGIN __END__