Debian Codegraph @

examples/point_test

raw
1 #!/usr/local/bin/perl -w
2 use strict;
3 use Tk;
4
5 my $mw = MainWindow->new;
6 my $pick = $mw->Label(-text => 'Pick', -relief => 'raised')->pack;
7 $mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
8
9 $pick->bind('<1>', \&PickStart);
10 $pick->bind('<ButtonRelease-1>', [\&PickWin,Ev('X'),Ev('Y')]);
11
12 MainLoop;
13
14
15 sub PickStart
16 {
17 my $w = shift;
18 $w->grabGlobal;
19 $w->configure(-cursor => 'hand2', -relief => 'sunken');
20 }
21
22 sub PickWin
23 {
24 my ($w,$x,$y) = @_;
25 $w->grabRelease;
26 $w->configure(-cursor => undef, -relief => 'raised');
27 my $id = $w->PointToWindow($x,$y);
28 my $depth = 0;
29 while ($id)
30 {
31 my @props = $w->property(list => $id);
32 printf("%s%08X %s\n",' ' x $depth,$id,join(' ',@props));
33 $depth++;
34 $id = $w->PointToWindow($x,$y,$id);
35 }
36 }
37