Moving the mouse pointer on behalf of the user
is commonly called "warping the pointer".
Have a look at the -warp portion of eventGenerate.
Here's a short example that warps the pointer from
a button down to a label when you click the button.
#!/usr/bin/perl
use Tk;
$m=Tk::MainWindow->new();
# create a button with a callback to do_warp
$b=$m->Button(-text => "Press Me", -command => \&do_warp);
# some filler labels so that the pointer warp is obvious
$filler1=$m->Label(-text => " ");
$filler2=$m->Label(-text => " ");
# this label is where the mouse pointer ends up
$l=$m->Label(-text => "Mouse ends up here");
$b->pack();
$filler1->pack();
$filler2->pack();
$l->pack();
MainLoop;
sub do_warp {
$l->eventGenerate('<ButtonPress>',-warp => 1);
}
You could also play with the -x/-y options to place
the pointer more specifically. Good luck.
Update: I should probably mention that moving
the pointer around is generally considered "bad juju",
and not the best UI design. |