summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-01-25 12:35:18 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-02-04 11:42:53 +0000
commit4a251da5bb79da00a2e720d136952114c816dd1e (patch)
tree242a84cfd689f38dfe70d4fc5cca5b00e753a35a /src/plugins/platforms/cocoa/qcocoaaccessibility.mm
parent1568074a60b109e35e2d5d940542038932f9358b (diff)
Accessibility OS X: Improve password handling
Set the right sub role (NSAccessibilitySecureTextFieldSubrole) and return the bullet point character for the text contents. This alignes the behavior with native widgets. Change-Id: I7305e08dca61097dd8c050aed64c792c06de0a4d Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaaccessibility.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index 723c341e59..97dde16a2b 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -195,6 +195,8 @@ NSString *macSubrole(QAccessibleInterface *interface)
QAccessible::State s = interface->state();
if (s.searchEdit)
return NSAccessibilitySearchFieldSubrole;
+ if (s.passwordEdit)
+ return NSAccessibilitySecureTextFieldSubrole;
return nil;
}
@@ -349,18 +351,23 @@ id getValueAttribute(QAccessibleInterface *interface)
const QAccessible::Role qtrole = interface->role();
if (qtrole == QAccessible::EditableText) {
if (QAccessibleTextInterface *textInterface = interface->textInterface()) {
- // VoiceOver will read out the entire text string at once when returning
- // text as a value. For large text edits the size of the returned string
- // needs to be limited and text range attributes need to be used instead.
- // NSTextEdit returns the first sentence as the value, Do the same here:
+
int begin = 0;
int end = textInterface->characterCount();
- // ### call to textAfterOffset hangs. Booo!
- //if (textInterface->characterCount() > 0)
- // textInterface->textAfterOffset(0, QAccessible2::SentenceBoundary, &begin, &end);
-
- QString text = textInterface->text(begin, end);
- //qDebug() << "text" << begin << end << text;
+ QString text;
+ if (interface->state().passwordEdit) {
+ // return round password replacement chars
+ text = QString(end, QChar(kBulletUnicode));
+ } else {
+ // VoiceOver will read out the entire text string at once when returning
+ // text as a value. For large text edits the size of the returned string
+ // needs to be limited and text range attributes need to be used instead.
+ // NSTextEdit returns the first sentence as the value, Do the same here:
+ // ### call to textAfterOffset hangs. Booo!
+ //if (textInterface->characterCount() > 0)
+ // textInterface->textAfterOffset(0, QAccessible2::SentenceBoundary, &begin, &end);
+ text = textInterface->text(begin, end);
+ }
return QCFString::toNSString(text);
}
}