Discussion:
[webkit-gtk] Keyboard nav out of a WebView
Michael Gratton
2018-09-06 09:35:00 UTC
Permalink
Hey all,

What's the best way to ensure that people move the keyboard focus out
of a WebView when they simply hit Tab/Shift-Tab when the first/last
element in the tab order focused, or press Down/Up and the view
scrolled to the bottom/top?

For Geary, I'd like to move the keyboard focus to the next widget when
appropriate, but I can't seem to work out how to do that, and it leads
to a pretty poor user experience

I've seen https://bugs.webkit.org/show_bug.cgi?id=157793, but is there
any know work-around?

Cheers,
//Mike
--
⊨ Michael Gratton, Percept Wrangler.
⚙ <http://mjog.vee.net/>
Michael Catanzaro
2018-09-10 22:08:08 UTC
Permalink
Post by Michael Gratton
I've seen https://bugs.webkit.org/show_bug.cgi?id=157793, but is
there any know work-around?
I can't think of any workaround. I think we just need to fix it.

Michael
Adrian Perez de Castro
2018-09-11 19:27:34 UTC
Permalink
Hello,
Post by Michael Catanzaro
Post by Michael Gratton
I've seen https://bugs.webkit.org/show_bug.cgi?id=157793, but is
there any know work-around?
I can't think of any workaround. I think we just need to fix it.
Here goes an *ugly* alternative:

1. Install a user script message handler with
webkit_user_content_manager_register_script_message_handler()

2. Add an injected JS script with
webkit_user_content_manager_add_script()

3. In your injected JS script, handle the “focusout” event on the document.
Determine which HTML element is the last one that can receive focus on
the page (tricky for pages which load content when scrolling). If that
last element loses focus, send an user script message.

4. In the handler for the user script message, use GTK+ functions to focus
the next widget i.e. gtk_widget_child_focus()

Certainly clunky, and I am not 100% sure whether it would work decently, but
at least the idea might be a starting point for you to take over from here.

Cheers,

-Adrián

Loading...