summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2025-06-14 22:57:59 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2025-06-16 16:41:00 +0200
commit9756f62a63f58098513343714b4c0367c0a62dde (patch)
tree4629c951f46b959e73a6fe4e7a1e33fe535ec630 /src/corelib/doc/snippets
parent4556caaa594e0e51984cc051df9fa0e2bdd9c0c6 (diff)
QLineEdit a11y: Report displayText on a11y layer
Instead of reporting no/empty text on the a11y layer when using a QLineEdit::EchoMode that doesn't display the actual text as is (e.g. in case of a password field), use QLineEdit::displayText, which already prevents exposing the actual text unless it's also displayed on screen. Previously, the character count and caret/cursor position was still reported for the actual text, but an empty string was reported for the text itself, which was inconsistent. (A cursor position of 3 within an allegedly empty text doesn't make sense, and empty text cannot have a character count of 5.) With this commit in place, entering "hello" in the QLineEdit from the sample app from QTBUG-109599 now results in replacement/mask characters as shown on screen being reported for the text on the a11y layer as well as long as QLineEdit::Password is used. Demo using Accerciser's IPython console on Linux, with the QLineEdit's accessible object selected in Accerciser's treeview of the sample app's a11y hierarchy. Without this commit in place: In [11]: text = acc.queryText() In [12]: text.characterCount Out[12]: 5 In [13]: text.getText(0, -1) Out[13]: '' With this commit in place: In [16]: text = acc.queryText() In [17]: text.characterCount Out[17]: 5 In [18]: text.getText(0, -1) Out[18]: '●●●●●' The Orca screen reader now announces "circle" as expected when moving the cursor between the individual characters. This also fixes the assert/crash seen with Narrator as mentioned in QTBUG-109599, due to the above-mentioned mismatch between reported character count and actual text length. (QWindowsUiaTextRangeProvider::ExpandToEnclosingUnit relies on the reported character count, then accesses the character by index, but the actual string was empty.) The QAccessibleLineEdit::text(QAccessible::Value) case previously had manual handling to report mask characters. Use the displayText there, too. Adjust tst_QAccessibility::lineEditTest accordingly and extend it to test the QAccessibleTextInterface in addition. Since mask characters for passwords in QLineEdit::displayText are platform-dependent, don't compare the text reported via a11y interfaces to a hard-coded string, but instead check it matches the displayText, but differs from the (plain) text. Fixes: QTBUG-109599 Pick-to: 6.10 6.9 Change-Id: Ifebb4502b71e11d431b708eea613cb2a10e3f237 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/doc/snippets')
0 files changed, 0 insertions, 0 deletions