File: drops

package info (click to toggle)
perl-tk 1%3A800.024-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 18,528 kB
  • ctags: 19,152
  • sloc: ansic: 206,767; perl: 40,255; makefile: 4,370; sh: 2,290; yacc: 762
file content (63 lines) | stat: -rwxr-xr-x 775 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/local/bin/perl


use Tk;

package Region;

sub new
{
 my ($class,%info) = @_;
 
 return bless \%info,$class;
}

sub children
{

}
 
package Hack;
use Tk::Xlib;
require Tk::Button;
use base  qw(Tk::Button);

sub Inquire
{
 my ($obj,$win) = @_;
 return Region->new(Display => $obj->Display, XID => $win);
}

sub site
{
 my ($w,$x,$y) = @_;
 my $r = $w->{regions};
 if (!defined $r)
  {
   my $dpy = $w->Display;
   $w->Inquire($dpy->RootWindow($dpy->DefaultScreen));
   $w->{regions} = $r;
  }
}

sub probe
{
 my ($w) = @_;
 my $e = $w->XEvent;
 my $x = $e->X;
 my $y = $e->Y;
 my $s = $w->site($x,$y);
 print "At $x,$y\n";
}

package main;

$top = MainWindow->new;

my $w = Hack->new($top,-text => 'Drag this');
$w->bind('<Any-Motion>','probe');
$w->pack;

MainLoop;