• Re: grab failed: another application has grab

    From Samson Patrick Awili-Jandara@21:1/5 to Peter Bielesch on Sun Oct 9 01:18:45 2022
    On Tuesday, 2 June 1998 at 17:00:00 UTC+10, Peter Bielesch wrote:
    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;

    Hi Peter,

    I hope the new millennium is treating you well. I hope you are alive as well. Tk for some reason does not allow grabbing windows not mapped to the screen. don't prematurely set these grabs and you won't have this problem.

    - Samson

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)