3

I have an editText that contains a drawableRight property. This editText is a search field, and the drawableRight is an "x" icon for clearing the text from the search field. When using Talkback (screen reader), I can't select the drawableRight to trigger my onTouch() event as it thinks I'm trying to tap on the editText as a whole.

I've tried to use .sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) on my editText drawable, but accessibility functions can only be used on elements that inherit from View.

When I try to access the drawable like this editText.getCompoundDrawables()[4] it doesn't give me any accessibility options, as it does not inherit from View. I need to find a way to let people with disabilities be able to tap on the "x" drawable from my edit text to clear the search bar text.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • Kindly add some relevant code so that the issue can be pointed out. – Adnan Temur Oct 09 '19 at 18:03
  • @AdnanTemur I can't share my code as it's confidential to my company. But it's a simple edit text with a "clear" icon set as a drawableRight. Talkback should be able to allow user to tap on that icon. If you turn on the talkback on your android and try to tap on the drawable on any edit text, it won't allow you. – Jessica Oliveira Oct 09 '19 at 18:38
  • Is the icon working on normal touch? – Adnan Temur Oct 09 '19 at 20:24
  • @AdnanTemur Yes, it works on normal touch. Unfortunately the solution I found (and disliked it), was to remove the drawableRight and simply add an image view on top of the edit text to mimic the functionality of a drawableRight. That way I was able to add `.sendAccessibilityEvent()` to it, as it inherits from View. – Jessica Oliveira Oct 21 '19 at 14:33
  • Why didn't you send two accessibilty events for the same view (EditText). – Adnan Temur Oct 21 '19 at 23:15
  • You might have implemented the onTouch listener for the drawable and editText inside an if statement. So if(it is drawable)drawable's accessibilty event, else {view's accessibilty event} – Adnan Temur Oct 21 '19 at 23:15
  • Hi, were you able to fix this problem? I am facing something similar. – h_k Nov 05 '19 at 15:25
  • @AdnanTemur, the DrawableRight isn't accessible when using the swipe gesture in TalkBack mode. It selects the entire `EditText`. Someone using TalkBack mode generally can't rely on their vision to reliably hit inside the DrawableRight bounds. The DrawableRight needs to be treated as a separate view... – h_k Nov 05 '19 at 15:30

0 Answers0