From: Óscar Fuentes on
Is there a simple mechanism for disabling all keyboard input for a given
toplevel and enabling it later?

Recursively disabling all widgets is too complex (have to remember which
widgets were already disabled, which widgets changed its state while the
keyboard was blocked, etc). I was thinking on creating a hidden toplevel
and put a grab on it, but I'll like to hear some opinions first.
From: Robert Heller on
At Tue, 09 Feb 2010 23:09:43 +0100 =?utf-8?Q?=C3=93scar_Fuentes?= <ofv(a)wanadoo.es> wrote:

>
> Is there a simple mechanism for disabling all keyboard input for a given
> toplevel and enabling it later?
>
> Recursively disabling all widgets is too complex (have to remember which
> widgets were already disabled, which widgets changed its state while the
> keyboard was blocked, etc). I was thinking on creating a hidden toplevel
> and put a grab on it, but I'll like to hear some opinions first.
>

man grab
man focus

Trick: create a canvas, but never map it. Set grab and focus there
during times that things are 'busy'. Keyboard / mouse events are
flushed away.


--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
heller(a)deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/

From: Óscar Fuentes on
Robert Heller <heller(a)deepsoft.com> writes:

>> Is there a simple mechanism for disabling all keyboard input for a given
>> toplevel and enabling it later?
>>
>> Recursively disabling all widgets is too complex (have to remember which
>> widgets were already disabled, which widgets changed its state while the
>> keyboard was blocked, etc). I was thinking on creating a hidden toplevel
>> and put a grab on it, but I'll like to hear some opinions first.
>>
>
> man grab
> man focus
>
> Trick: create a canvas, but never map it. Set grab and focus there
> during times that things are 'busy'. Keyboard / mouse events are
> flushed away.

Thanks for the advice. I've checked that setting the focus on the main
toplevel (which has no problematic keyboard bindings) does the trick,
but what you suggest is more robust.
From: Óscar Fuentes on
Robert Heller <heller(a)deepsoft.com> writes:

>> Is there a simple mechanism for disabling all keyboard input for a
>> given toplevel and enabling it later?
>
> man grab
> man focus
>
> Trick: create a canvas, but never map it. Set grab and focus there
> during times that things are 'busy'. Keyboard / mouse events are
> flushed away.

It seems that it is not possible to set the focus on an unmapped widget.
From: Robert Heller on
At Wed, 10 Feb 2010 15:37:08 +0100 =?utf-8?Q?=C3=93scar_Fuentes?= <ofv(a)wanadoo.es> wrote:

>
> Robert Heller <heller(a)deepsoft.com> writes:
>
> >> Is there a simple mechanism for disabling all keyboard input for a
> >> given toplevel and enabling it later?
> >
> > man grab
> > man focus
> >
> > Trick: create a canvas, but never map it. Set grab and focus there
> > during times that things are 'busy'. Keyboard / mouse events are
> > flushed away.
>
> It seems that it is not possible to set the focus on an unmapped widget.
>

Huh? Sure it is -- I do this all of the time. By 'unmapped' what I
mean is creating a widget (such as a canvas, which normally will accept
both keyboard and mouse events) on the same toplevel as you are
displaying and then never packing, placing, or gridding it. I would
normally do this on the toplevel widget, which is generally always
displayed.


--
Robert Heller -- 978-544-6933
Deepwoods Software -- Download the Model Railroad System
http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows
heller(a)deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/