diff options
author | michaelvogt <michael@vaadin.com> | 2013-03-20 18:09:49 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-03-28 16:03:45 +0000 |
commit | 833b117b967e3466b37bf95d3f801e927e0e5c45 (patch) | |
tree | 3b2451cd1d56533823641340fba863b9080e648e /client | |
parent | a92166902c73a5b0e1e8e30e4876bc553f8779ab (diff) | |
download | vaadin-framework-833b117b967e3466b37bf95d3f801e927e0e5c45.tar.gz vaadin-framework-833b117b967e3466b37bf95d3f801e927e0e5c45.zip |
WAI-ARIA button (#11380)
Accessibility functions for Button
Change-Id: I12ddfd8232d4d35135add1cb4406bfdc20b758f2
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VButton.java | 10 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/button/ButtonConnector.java | 7 |
2 files changed, 9 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/ui/VButton.java b/client/src/com/vaadin/client/ui/VButton.java index decfb7c0cc..28a2221380 100644 --- a/client/src/com/vaadin/client/ui/VButton.java +++ b/client/src/com/vaadin/client/ui/VButton.java @@ -16,6 +16,7 @@ package com.vaadin.client.ui; +import com.google.gwt.aria.client.Roles; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.NativeEvent; @@ -25,7 +26,6 @@ import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.ui.Accessibility; import com.google.gwt.user.client.ui.FocusWidget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; @@ -103,7 +103,7 @@ public class VButton extends FocusWidget implements ClickHandler { | Event.KEYEVENTS); // Add a11y role "button" - Accessibility.setRole(getElement(), Accessibility.ROLE_BUTTON); + Roles.getButtonRole().set(getElement()); getElement().appendChild(wrapper); wrapper.appendChild(captionElement); @@ -357,14 +357,12 @@ public class VButton extends FocusWidget implements ClickHandler { this.enabled = enabled; if (!enabled) { cleanupCaptureState(); - Accessibility.removeState(getElement(), - Accessibility.STATE_PRESSED); super.setTabIndex(-1); } else { - Accessibility.setState(getElement(), - Accessibility.STATE_PRESSED, "false"); super.setTabIndex(tabIndex); } + + Roles.getButtonRole().setAriaDisabledState(getElement(), !enabled); } } diff --git a/client/src/com/vaadin/client/ui/button/ButtonConnector.java b/client/src/com/vaadin/client/ui/button/ButtonConnector.java index 9733d206c7..fff983c168 100644 --- a/client/src/com/vaadin/client/ui/button/ButtonConnector.java +++ b/client/src/com/vaadin/client/ui/button/ButtonConnector.java @@ -24,6 +24,7 @@ import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; import com.vaadin.client.EventHelper; import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.communication.StateChangeEvent; @@ -83,8 +84,10 @@ public class ButtonConnector extends AbstractComponentConnector implements if (getIcon() != null) { if (getWidget().icon == null) { getWidget().icon = new Icon(getConnection()); - getWidget().wrapper.insertBefore( - getWidget().icon.getElement(), + Element iconElement = getWidget().icon.getElement(); + iconElement.setAttribute("alt", getState().iconAltText); + + getWidget().wrapper.insertBefore(iconElement, getWidget().captionElement); } getWidget().icon.setUri(getIcon()); |