Re: gtk_widget_grab_focus sets scrollbar adjustments to 0



On Mon, 2015-12-28 at 18:01 +0800, Franco Broi wrote:
Hi

I have a drawingarea inside a scrolled window for which I'd like to
grab
the focus so the user can use keyboard inputs but I want to do it
without changing the scrolled window position. What I'm finding is
the
gtk_widget_grab_focus call on the drawable results in the scrolled
window adjustments being set to zero.

[...]

I can see the code in gtk_container_real_set_focus_child calling
gtk_adjustment_clamp_page but don't understand why and I don't see
any
way to stop it from doing it.
[...]

Hi,
   the reasoning is that usually focus is not given to the direct child
of a scrolled window, but to another grandchild.

This usually makes sense so that when using keynav and tabbing from
widget to widget inside a scrolled area, the scrolled window will
automatically adjust itself to reveal the new button/entry/widget which
may otherwise be hidden (so the user doesnt end up having to manually
move the scrollbars to see what widget is focused).

For your case, you should be able to opt out by simply clearing the
focus adjustments with the gtk_container_set_focus_[v/h]adjustment()
APIs.

Cheers,
    -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]