summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-10-14 20:41:07 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-20 02:12:15 +0200
commit19b3e6489dd2f795e0bbacd5d0abe74b8ef8021c (patch)
tree345686288c630ffd4528487bb57253b1f2bfaf52 /src
parent24d926cb8fb421b751b5be97fd214469e4c429c2 (diff)
Android: Accessibilty: Handle text better
Try harder to actually return text, before TalkBack would not read the contents of line edits and other text widgets. Change-Id: Ibb9bb8ac4a2728674f6f5ccf29eda5ed66a81a34 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/android/src/androidjniaccessibility.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/plugins/platforms/android/src/androidjniaccessibility.cpp b/src/plugins/platforms/android/src/androidjniaccessibility.cpp
index 07f3371e72..a27d9f5aed 100644
--- a/src/plugins/platforms/android/src/androidjniaccessibility.cpp
+++ b/src/plugins/platforms/android/src/androidjniaccessibility.cpp
@@ -164,7 +164,7 @@ if (!clazz) { \
//__android_log_print(ANDROID_LOG_FATAL, m_qtTag, m_methodErrorMsg, METHOD_NAME, METHOD_SIGNATURE);
-#define CALL_METHOD(OBJECT, METHOD_NAME, METHOD_SIGNATURE, VALUE) \
+#define CALL_METHOD(OBJECT, METHOD_NAME, METHOD_SIGNATURE, ...) \
{ \
jclass clazz = env->GetObjectClass(OBJECT); \
jmethodID method = env->GetMethodID(clazz, METHOD_NAME, METHOD_SIGNATURE); \
@@ -172,7 +172,7 @@ if (!clazz) { \
__android_log_print(ANDROID_LOG_WARN, m_qtTag, m_methodErrorMsg, METHOD_NAME, METHOD_SIGNATURE); \
return; \
} \
- env->CallVoidMethod(OBJECT, method, VALUE); \
+ env->CallVoidMethod(OBJECT, method, __VA_ARGS__); \
}
@@ -201,9 +201,21 @@ if (!clazz) { \
}
QAccessible::State state = iface->state();
- QString desc = iface->text(QAccessible::Name);
+ // try to fill in the text property, this is what the screen reader reads
+ QString desc = iface->text(QAccessible::Value);
+ if (desc.isEmpty())
+ desc = iface->text(QAccessible::Name);
if (desc.isEmpty())
desc = iface->text(QAccessible::Description);
+ if (QAccessibleTextInterface *textIface = iface->textInterface()) {
+ if (textIface->selectionCount() > 0) {
+ int startSelection;
+ int endSelection;
+ textIface->selection(0, &startSelection, &endSelection);
+ CALL_METHOD(node, "setTextSelection", "(II)V", startSelection, endSelection)
+ }
+ }
+
if ((iface->role() != QAccessible::NoRole) &&
(iface->role() != QAccessible::Client) &&
(iface->role() != QAccessible::Pane)) {