Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ensuring that widget with focus is visible in widget::scrolledwindow

50 views
Skip to first unread message

Óscar Fuentes

unread,
Dec 26, 2018, 8:44:58 AM12/26/18
to
I'm using tklib's widget::scrolledwindow for displaying several widgets
(entry's, comboboxes, etc).

When they don't fit on the scrolledwindow's area, scroll bars are shown
as expected. If the user moves from one widget to another with TAB,
eventually the focus jumps to one of the widgets that is out of sight,
which is confusing, to say the least.

What I need is to move the scroll area to ensure that the widget that
has the focus is visible, but looking at widget::scrolledwindow's source
code I see no obvious approach to this.

Hints appreciated.

Alexandru

unread,
Dec 26, 2018, 9:20:01 AM12/26/18
to
If there is no out of the box function for this, it can be implemented by adding a binding to the <Focus> event and checking if the widget is visible or not.

Regards
Alexandru

Alexandru

unread,
Dec 26, 2018, 9:20:35 AM12/26/18
to
But I never tested this...

Óscar Fuentes

unread,
Dec 26, 2018, 9:35:22 AM12/26/18
to
I guess there is a generic method for checking when a window is visible
(winfo something) but I see no way of commanding scrolledwindow to
adjust the view to show the widget.

Alexandru

unread,
Dec 26, 2018, 9:56:14 AM12/26/18
to
Since scrolledwindow uses normal scroll bars, it should be possible to send "xview" or "yview" to those to set the position. See the manual on scrollbar.

briang

unread,
Dec 26, 2018, 3:43:35 PM12/26/18
to
You will most likely have to reach in and modify/command the scrollbar widgets directly:

widget::scrolledwindow .w
> .w
winfo children .w
> .w.hscroll .wvscroll
.w.hscroll set 0.7

You'll have to compute what the offset percentage needs to be to make the desired part of the frame visible.

-Brian

Óscar Fuentes

unread,
Mar 27, 2019, 9:15:40 PM3/27/19
to
Sorry for the long delay. Today I returned to the problem.

At the end the solution was very simple. The widget::scrolledwindow
contains an ScrollableFrame (from BWidget package) which provides a
`see' command.

If `w' is a widget contained in the ScrollableFrame s,

bind w <FocusIn> {s see w}

does the trick.

Thank you Alexandru and briang.
0 new messages