Skip to content

Commit 43448dd

Browse files
committed
8284544: [Win] Name-Property of Spinner cannot be changed
Reviewed-by: kcr, aghaisas
1 parent 09922d5 commit 43448dd

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
lines changed

modules/javafx.controls/src/main/java/javafx/scene/control/Spinner.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ private void setText(T value) {
769769
}
770770
}
771771

772-
notifyAccessibleAttributeChanged(AccessibleAttribute.TEXT);
772+
notifyAccessibleAttributeChanged(AccessibleAttribute.VALUE_STRING);
773773
if (text == null) {
774774
if (value == null) {
775775
getEditor().clear();
@@ -834,7 +834,7 @@ static BigDecimal wrapValue(BigDecimal value, BigDecimal min, BigDecimal max) {
834834
@Override
835835
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
836836
switch (attribute) {
837-
case TEXT: {
837+
case VALUE_STRING: {
838838
T value = getValue();
839839
SpinnerValueFactory<T> factory = getValueFactory();
840840
if (factory != null) {
@@ -845,6 +845,15 @@ public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object...
845845
}
846846
return value != null ? value.toString() : "";
847847
}
848+
849+
case TEXT: {
850+
String accText = getAccessibleText();
851+
return (accText != null) ? accText : "";
852+
}
853+
854+
case EDITABLE:
855+
return isEditable();
856+
848857
default: return super.queryAccessibleAttribute(attribute, parameters);
849858
}
850859
}

modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java

+9
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,11 @@ public void sendNotification(AccessibleAttribute notification) {
801801
macNotification = MacNotification.NSAccessibilityValueChangedNotification;
802802
}
803803
break;
804+
case VALUE_STRING:
805+
if (getAttribute(ROLE) == AccessibleRole.SPINNER) {
806+
macNotification = MacNotification.NSAccessibilityValueChangedNotification;
807+
}
808+
break;
804809
case PARENT:
805810
if (peer != 0L) {
806811
_invalidateParent(peer);
@@ -1210,6 +1215,10 @@ private MacVariant accessibilityAttributeValue(long attribute) {
12101215
jfxAttr = TEXT;
12111216
map = MacVariant::createNSString;
12121217
break;
1218+
case SPINNER:
1219+
jfxAttr = VALUE_STRING;
1220+
map = MacVariant::createNSString;
1221+
break;
12131222
case CHECK_BOX:
12141223
case TOGGLE_BUTTON:
12151224
jfxAttr = SELECTED;

modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java

+26-6
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,26 @@ public void sendNotification(AccessibleAttribute notification) {
363363
WinVariant vn = new WinVariant();
364364
vn.vt = WinVariant.VT_BSTR;
365365
vn.bstrVal = value;
366-
if (getAttribute(ROLE) == AccessibleRole.SPINNER) {
367-
UiaRaiseAutomationPropertyChangedEvent(peer, UIA_NamePropertyId, vo, vn);
368-
} else {
369-
/* Combo and Text both implement IValueProvider */
370-
UiaRaiseAutomationPropertyChangedEvent(peer, UIA_ValueValuePropertyId, vo, vn);
371-
}
366+
/* Combo and Text both implement IValueProvider */
367+
UiaRaiseAutomationPropertyChangedEvent(peer, UIA_ValueValuePropertyId, vo, vn);
372368
}
373369

374370
if (selectionRange != null || documentRange != null) {
375371
UiaRaiseAutomationEvent(peer, UIA_Text_TextChangedEventId);
376372
}
377373
break;
374+
case VALUE_STRING:
375+
String val = (String)getAttribute(VALUE_STRING);
376+
if (val != null) {
377+
WinVariant vo = new WinVariant();
378+
vo.vt = WinVariant.VT_BSTR;
379+
vo.bstrVal = "";
380+
WinVariant vn = new WinVariant();
381+
vn.vt = WinVariant.VT_BSTR;
382+
vn.bstrVal = val;
383+
UiaRaiseAutomationPropertyChangedEvent(peer, UIA_ValueValuePropertyId, vo, vn);
384+
}
385+
break;
378386
case EXPANDED: {
379387
Boolean expanded = (Boolean)getAttribute(EXPANDED);
380388
if (expanded != null) {
@@ -686,6 +694,9 @@ private long GetPatternProvider(int patternId) {
686694
impl = patternId == UIA_ExpandCollapsePatternId ||
687695
patternId == UIA_ValuePatternId;
688696
break;
697+
case SPINNER:
698+
impl = patternId == UIA_ValuePatternId;
699+
break;
689700
case SCROLL_BAR:
690701
case SLIDER:
691702
case PROGRESS_INDICATOR:
@@ -1319,6 +1330,7 @@ private boolean get_IsReadOnly() {
13191330
case SCROLL_BAR: return true;
13201331
case TEXT_FIELD:
13211332
case TEXT_AREA:
1333+
case SPINNER:
13221334
case COMBO_BOX: return Boolean.FALSE.equals(getAttribute(EDITABLE));
13231335
default:
13241336
}
@@ -1367,6 +1379,14 @@ private void SetValueString(String val) {
13671379

13681380
private String get_ValueString() {
13691381
if (isDisposed()) return null;
1382+
AccessibleRole role = (AccessibleRole)getAttribute(ROLE);
1383+
if (role != null) {
1384+
switch (role) {
1385+
case SPINNER:
1386+
return (String)getAttribute(VALUE_STRING);
1387+
default:
1388+
}
1389+
}
13701390
return (String)getAttribute(TEXT);
13711391
}
13721392

modules/javafx.graphics/src/main/java/javafx/scene/AccessibleAttribute.java

+13
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,19 @@ public enum AccessibleAttribute {
774774
*/
775775
VALUE(Double.class),
776776

777+
/**
778+
* Returns the value as string for the node.
779+
* <ul>
780+
* <li>Used by: Spinner </li>
781+
* <li>Needs notify: yes </li>
782+
* <li>Return Type: {@link String} </li>
783+
* <li>Parameters: </li>
784+
* </ul>
785+
*
786+
* @since 22
787+
*/
788+
VALUE_STRING(String.class),
789+
777790
/**
778791
* Returns the vertical scroll bar for the node.
779792
* <ul>

0 commit comments

Comments
 (0)