Debian Codegraph @

examples/bindtest

raw
1 #!/usr/local/bin/perl -w
2 use Tk;
3 use Tk::Menubar;
4
5 my $mw = MainWindow->new;
6 my $mb = $mw->Menubar;
7 $mb->Menubutton(-text => '~File', -font => 'fixed', -menuitems =>
8 [
9 [Button => '~Quit', -font => 'fixed', -command => [$mw,'destroy']]
10 ]);
11 my $f = $mw->Frame(-width => 100, -height => 100, -borderwidth => 2,
12 -takefocus => 1,
13 #-highlightborderwidth=> 3, # XXX Does not work (anymore?)
14 #-highlightforeground => 'black' # XXX Does not work (anymore?)
15 )->pack;
16
17 my $qual;
18 foreach $qual ('',qw(Meta- Shift- Control- Alt-))
19 {
20 $f->bind("<${qual}KeyPress>",[ \&showit, "${qual}KeyPress" ]);
21 }
22
23 $mw->update;
24 $f->focus;
25
26 MainLoop;
27
28 sub showit
29 {
30 my ($w,$kind) = @_;
31 my $ev = $w->XEvent;
32 print "$kind ",$ev->K," ",$ev->A,"\n";
33 }