Menu

#169 Focus behaviour changes

open
55. [focus] (1)
5
2014-08-16
2005-03-31
Simon White
No

Possibility of modifing/extending the behaviour of focus?

Background: Tcl/Tk is running on an embedded computer
running Linux with X without mouse, touch screen and
only a minimilist keyboard. The TclTk is the only
application running under X and there is no Windows
manager.

There are serious problems with focus becoming lost or
not ending up in the correct place for the following
reasons:

-To change the screen contents we must bring up a popup
allowing selection of the new screen. The popup
restores focus to a widget that nolonger exists.

-Focus between different toplevels appears not to be
serialised. For example if you focus on widget then
toplevel/menu the final focus position is a bit random
(especially if widget is in the process of mapping itself).

-If there is a focus on a maping widget and then
becomes unmapped the focus event gets held off until
the next time the widget becomes shown.

-If we focus on a mapping widget and then a popup
appears before the focus event occurs then focus will
be restored to the wrong location as it stores what
has focus rather than what was the last thing you asked
for focus on.

-Multiple focus events can come in the wrong order if
you focus on a mapping widget and then focus on an
already mapped widget.

Suggestions for fixes:

-Add a "-pending" option for focus to return always to
the last asked for focus position. Also make this work
correctly with -lastfor.

-Allow widget to pick up pending focus (by default?),
perhaps a switch or a global option.

-Providing ability to modify tkPriv with directly
modifying the private variable.

-A new focus request will cancel any pending focus request.

-A focus request on a widget being removed from the
screen becomes deleted (note focus -pending would need
restoring in this case).

Is presumed that normally [focus -pending] and [focus]
will always return the same value unless we really have
a pending request.

Discussion