summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/uiautomation/qwindowsuiaexpandcollapseprovider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/uiautomation/qwindowsuiaexpandcollapseprovider.cpp')
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiaexpandcollapseprovider.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaexpandcollapseprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaexpandcollapseprovider.cpp
index 33900a8d66..8eb9baa8ef 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaexpandcollapseprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaexpandcollapseprovider.cpp
@@ -16,6 +16,14 @@ QT_BEGIN_NAMESPACE
using namespace QWindowsUiAutomation;
+static bool isExpanded(QAccessibleInterface *accessible)
+{
+ Q_ASSERT(accessible);
+ if (accessible->role() == QAccessible::MenuItem)
+ return accessible->childCount() > 0 && !accessible->child(0)->state().invisible;
+ else
+ return accessible->state().expandable && accessible->state().expanded;
+}
QWindowsUiaExpandCollapseProvider::QWindowsUiaExpandCollapseProvider(QAccessible::Id id) :
QWindowsUiaBaseProvider(id)
@@ -36,7 +44,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::Expand()
if (!actionInterface)
return UIA_E_ELEMENTNOTAVAILABLE;
- if (accessible->childCount() > 0 && accessible->child(0)->state().invisible)
+ if (!isExpanded(accessible))
actionInterface->doAction(QAccessibleActionInterface::showMenuAction());
return S_OK;
@@ -54,7 +62,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::Collapse()
if (!actionInterface)
return UIA_E_ELEMENTNOTAVAILABLE;
- if (accessible->childCount() > 0 && !accessible->child(0)->state().invisible)
+ if (isExpanded(accessible))
actionInterface->doAction(QAccessibleActionInterface::showMenuAction());
return S_OK;
@@ -72,9 +80,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::get_ExpandCollapseS
if (!accessible)
return UIA_E_ELEMENTNOTAVAILABLE;
- if (accessible->childCount() > 0)
- *pRetVal = accessible->child(0)->state().invisible ?
- ExpandCollapseState_Collapsed : ExpandCollapseState_Expanded;
+ *pRetVal = isExpanded(accessible) ? ExpandCollapseState_Expanded : ExpandCollapseState_Collapsed;
return S_OK;
}