diff options
2 files changed, 32 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java index 8442d20531..0dec3ceb7b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/win32/org/eclipse/swt/accessibility/Accessible.java @@ -1558,7 +1558,8 @@ public class Accessible { if (accessibleActionListeners.size() > 0 || accessibleAttributeListeners.size() > 0 || accessibleHyperlinkListeners.size() > 0 || accessibleTableListeners.size() > 0 || accessibleTableCellListeners.size() > 0 || accessibleTextExtendedListeners.size() > 0 || - accessibleValueListeners.size() > 0 || getRelationCount() > 0) { + accessibleValueListeners.size() > 0 || getRelationCount() > 0 + || (control instanceof Button && ((control.getStyle() & SWT.RADIO) != 0))) { if (objIServiceProvider == null) createIServiceProvider(); COM.MoveMemory(ppvObject, new int /*long*/[] { objIServiceProvider.getAddress() }, OS.PTR_SIZEOF); AddRef(); @@ -1721,7 +1722,8 @@ public class Accessible { if (accessibleActionListeners.size() > 0 || accessibleAttributeListeners.size() > 0 || accessibleHyperlinkListeners.size() > 0 || accessibleTableListeners.size() > 0 || accessibleTableCellListeners.size() > 0 || accessibleTextExtendedListeners.size() > 0 || - accessibleValueListeners.size() > 0 || getRelationCount() > 0) { + accessibleValueListeners.size() > 0 || getRelationCount() > 0 + || (control instanceof Button && ((control.getStyle() & SWT.RADIO) != 0))) { if (objIAccessible2 == null) createIAccessible2(); COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible2.getAddress() }, OS.PTR_SIZEOF); AddRef(); @@ -2878,11 +2880,24 @@ public class Accessible { int groupLevel = 0; COM.MoveMemory(pGroupLevel, new int [] { groupLevel }, 4); //get the children of the parent - //collect all children with the same role, if none, then 0 (for N/A) + //count all children with the same role, if none, then 0 (for N/A) + //find this control's 1-based index in the same-type children of the parent (0 for N/A) int similarItemsInGroup = 0; - COM.MoveMemory(pSimilarItemsInGroup, new int [] { similarItemsInGroup }, 4); - //find this guy's 1-based index in the children of the parent (0 for N/A) int positionInGroup = 0; + if (control instanceof Button && ((control.getStyle() & SWT.RADIO) != 0)) { + /* We currently only determine position and count for radio buttons. */ + Control [] children = control.getParent().getChildren(); + positionInGroup = 1; + similarItemsInGroup = 1; + for (int i = 0; i < children.length; i++) { + Control child = children[i]; + if (child instanceof Button && ((child.getStyle() & SWT.RADIO) != 0)) { + if (child == control) positionInGroup = similarItemsInGroup; + else similarItemsInGroup++; + } + } + } + COM.MoveMemory(pSimilarItemsInGroup, new int [] { similarItemsInGroup }, 4); COM.MoveMemory(pPositionInGroup, new int [] { positionInGroup }, 4); if (DEBUG) print(this + ".IAccessible2::get_groupPosition() returning" + hresult(groupLevel == 0 && similarItemsInGroup == 0 && positionInGroup == 0 ? COM.S_FALSE : COM.S_OK)); if (groupLevel == 0 && similarItemsInGroup == 0 && positionInGroup == 0) return COM.S_FALSE; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index b0612c48a8..4b44a64e42 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -1215,6 +1215,18 @@ LRESULT WM_GETDLGCODE (int /*long*/ wParam, int /*long*/ lParam) { return result; } +LRESULT WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) { + /* + * Ensure that there is an accessible object created for this + * control because support for radio button position in group + * accessibility is implemented in the accessibility package. + */ + if ((style & SWT.RADIO) != 0) { + if (accessible == null) accessible = new_Accessible (this); + } + return super.WM_GETOBJECT (wParam, lParam); +} + LRESULT WM_KILLFOCUS (int /*long*/ wParam, int /*long*/ lParam) { LRESULT result = super.WM_KILLFOCUS (wParam, lParam); if ((style & SWT.PUSH) != 0 && getDefault ()) { |