From b53dcb4e67a4f630c8108085967a7842b4d5d95e Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Wed, 14 Dec 2022 17:40:22 +0100 Subject: [PATCH] Treat the accessible non-editable combobox as ButtonMenu on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Following the system design, we should treat the non-editable combobox as a ButtonMenu. All of the similar elements in macOS's UI are called ButtonMenu with the screen reader. This fixes the case when ctrl+option+space does not invoke the popup menu with options. Fixes: QTBUG-106162 Change-Id: I0b439c56d72d1fe5b32a60eb7c001f863c00adc1 Reviewed-by: Jan Arve Sæther Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaaccessibility.mm | 2 ++ src/widgets/accessible/complexwidgets.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 535d0a3d8a..dc2baa6961 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -155,6 +155,8 @@ NSString *macRole(QAccessibleInterface *interface) if (roleMap.contains(qtRole)) { // MAC_ACCESSIBILTY_DEBUG() << "return" << roleMap[qtRole]; + if (roleMap[qtRole] == NSAccessibilityComboBoxRole && !interface->state().editable) + return NSAccessibilityMenuButtonRole; if (roleMap[qtRole] == NSAccessibilityTextFieldRole && interface->state().multiLine) return NSAccessibilityTextAreaRole; return roleMap[qtRole]; diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index df81713d72..624090a2af 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -366,6 +366,7 @@ QAccessible::State QAccessibleComboBox::state() const s.expandable = true; s.expanded = isValid() && comboBox()->view()->isVisible(); + s.editable = comboBox()->isEditable(); return s; }