Android Talkback 未针对网络注册 onFocus.如何使用 Android Talkback 操纵可访问性焦点? [英] Android Talkback not registering onFocus for web. How do I manipulate accessibility focus with Android Talkback?

查看:33
本文介绍了Android Talkback 未针对网络注册 onFocus.如何使用 Android Talkback 操纵可访问性焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,Android Talkback 没有注册 onFocus 事件.我知道 onFocus 事件从未注册过,因为屏幕阅读器使用的是一种特殊类型的辅助功能焦点.那么,我们如何才能推动/操纵无障碍功能的焦点以向用户提供更好的体验?

As the title says, Android Talkback is not registering the onFocus event. I understand that the onFocus event is not ever registered since the screen reader is using a special type of accessibility focus. How, then, can we drive/manipulate the accessibility focus to provide the user a better experience?

我这里有一个例子:https://codesandbox.io/s/r54j2mqrl4.所以这里 console.log("hello!") 没有在移动 Android Talkback 中为我注册,但是它在桌面 Mac OSX 上正确注册(没有屏幕阅读器).我正在使用 Tab 键进行导航.

I have an example here: https://codesandbox.io/s/r54j2mqrl4 . So here the console.log("hello!") is not registering for me in mobile Android Talkback, however it is registering correctly on desktop mac OSX(with no screen reader on). I am using the tab key to navigate.

是否有类似 onFocus 事件可用于 Android Talkback 的辅助功能焦点?

Is there something similar to an onFocus event to use for Android Talkback's accessibility focus?

提前感谢您抽出宝贵时间.

Thank you in advance for your time.

设备和版本:

移动 Android 对讲:三星 Galaxy Tab S2,Android 7.0 版,Google Chrome 62.0.3202.84

Mobile Android Talkback: Samsung Galaxy Tab S2, Android version 7.0, Google Chrome 62.0.3202.84

桌面 Mac OSX:macOS Sierra 10.12.6,谷歌 Chrome 61.0.3163.100

Desktop Mac OSX: macOS Sierra 10.12.6, Google Chrome 61.0.3163.100

推荐答案

.focus()"方法理论上应该有效.如果正在接收焦点"的事物也不会获得可访问性焦点,问题就会出现.Android 无障碍服务只能以无障碍功能为重点,同时关注无障碍功能.

The ".focus()" method theoretically should work. The problem would come into play in the event that the thing that was receiving "focus" would not also receive accessibility focus. An Android Accessibility Service can only accessibility focus things that are also Accessibility focusable.

不幸的是,您不能直接从 Javascript 操作 Accessibility Focus,只能操作.话虽如此,当您使用 Android 并且某些内容需要焦点时,这通常表明可访问性焦点也将与焦点一起移至该项目.在 TalkBack 术语中,这就是 Tab 导航的工作方式,Accessibility Focus 只是跟随输入焦点.它并不完美,但可以合理地期望 Focus 和 Accessibility Focus 保持一致.虽然并非总是如此:EditTexts 可以在 TalkBack 中处于准聚焦/非聚焦状态,这是有充分理由的……您可能需要在该字段仍然具有光标(输入焦点)时与屏幕键盘进行交互.

Unfortunately you cannot manipulate Accessibility Focus directly from Javascript, only focus. This being said, when you're in Android and something requests focus, this usually suggests accessibility focus will also move to that item along with focus. In TalkBack terms, this is how Tab navigation works, Accessibility Focus just follows input focus around. It's not perfect, but it's a reasonable expectation that Focus and Accessibility Focus want to be the same. Though not always: EditTexts can be in an quazi focused/unfocused state in TalkBack, for good reason... you may need to interact with the onscreen keyboard while the field still has the cursor (input focus).

如果以下情况为真:

  • 您的元素是可访问性的焦点
  • 你的元素是可聚焦的
  • A11yFocusable 的东西和可聚焦的东西是一样的,而不仅仅是后代(非常重要).

您可以通过在 Android 设备监视器中进行探索来轻松确认上述三件事.三重检查您没有关注您所设想的获得可访问性焦点的事物(例如元素的子元素).

You can easily confirm the above three things by exploring in Android Device monitor. Triple check that you aren't focusing something (like a child of the element) of the thing that you are envision getting accessibility focus.

如果在此之后,您对该事物调用 .focus() 并且它不起作用,则您实际上已经在用于呈现 HTML/Javascript 内容的 webview 中发现了一个错误,并且没有任何内容你可以这样做.

If, after that, you call .focus() on the thing, and it doesn't work, you have essentially found a bug in the webview you are using to render your HTML/Javascript content, and no there is nothing you can do about it.

这篇关于Android Talkback 未针对网络注册 onFocus.如何使用 Android Talkback 操纵可访问性焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆