I have a problem with the grab command
as used e.g. in Tk::Dialog
( Version Tk400.200 and Tk400.202 )
When a toplevel window tries to get grab while
the user presses <Button1> with the mouse cursor
on the frame of another window the following error occurs:
Tk::Error: grab failed: another application has grab at grabexample.pl
line 23.
Tk callback for grab
[\&main::__ANON__,{}]
Tk callback for .button
(command bound to event) at
/usr/local/perl5/lib/site_perl/auto/Tk/Error.al line 13.
I have tried to analyse the error but I lost focus
in the X11 stuff at
./pTk/mTk/tkGrab.c : Tk_Grab()
The error is the same on HP, SCO and Linux
How can I avoid this situation. I cannot use
the returncode of the grab command, cause it
returns just an empty string.
Peter
My example:
- pressed 'pressme'
- pressed frame of 'pressme'
- wait 3 seconds
- error occurs
#!/usr/local/bin/perl5
use Tk;
my $top = MainWindow->new;
my $win = $top->Toplevel;
$win->Button(
-text=>'pressyou',
-command => [
sub {
$_[0]->withdraw;
$_[0]->grabRelease;
},$win
]
pack;$win->withdraw;
$top->Button(
-text=>'pressme',
-command => [
sub {
sleep(3); # Simulate delayed Popup
$_[0]->Popup;
$_[0]->grab;
},$win
]
pack;MainLoop;
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 353 |
Nodes: | 16 (2 / 14) |
Uptime: | 78:48:46 |
Calls: | 7,639 |
Files: | 12,802 |
Messages: | 5,691,831 |