~ubuntu-branches/ubuntu/maverick/perl-tk/maverick

« back to all changes in this revision

Viewing changes to examples/bindtest

  • Committer: Bazaar Package Importer
  • Author(s): Colin Tuckley
  • Date: 2010-05-30 09:19:40 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100530091940-wbmq9bloo92t9m6x
Tags: 1:804.029-1
* New Upstream Release (Closes: #578814).
* Added debian/watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}