-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDragShadowToplevelTest
65 lines (48 loc) · 1.35 KB
/
DragShadowToplevelTest
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
64
65
### Test for the DragShadow Widget #########
###
### Expected Results:
### A Grey window should display.
### After 2 seconds, and dark grey frame should appear inside the frame
### After 2 seconds, the frame should disappear
###
use Tk;
use Tk::DragShadowToplevel;
my $mw = new MainWindow ();
my $Frame = $mw->Frame(-width => 100, -height => 200, -bg => 'white');
$Frame->pack();
my $widget;
my $geometry;
my ($offsetX, $offsetY) = (0,0);
$mw->bind('<B1-Motion>', sub{
my $w = shift;
my $ev = $w->XEvent();
my $x = $ev->X;
my $y = $ev->Y;
#print "X = $x Y=$y\n";
$widget->MoveToplevelWindow($x-$offsetX,$y-$offsetY);
}
);
$mw->bind('<ButtonPress-1>', sub{
my $w = shift;
my $ev = $w->XEvent();
my $x = $ev->X;
my $y = $ev->Y;
print "x/y = $x/$y\n";
#$geometry = "100x200+100+100";
my $geometry = $mw->geometry;
print "MW G = $geometry \n";
print "FrameG = ".$Frame->geometry."\n";
print "Frame Root x/y ".$Frame->rootx." ".$Frame->rooty."\n";
my ($rootx,$rooty) = ( $Frame->rootx, $Frame->rooty);
($offsetX, $offsetY) = ($x-$rootx, $y-$rooty);
$geometry = $Frame->reqwidth."x".$Frame->reqheight."+".$Frame->rootx."+".$Frame->rooty;
$widget = $mw->DragShadowToplevel(-geometry => $geometry);
}
);
$mw->bind('<B1-ButtonRelease>', sub{
print "button release\n";
$widget->destroy if( defined( $widget ));
$widget = undef;
}
);
MainLoop;