Author: [EMAIL PROTECTED]
Date: Thu Dec  4 14:14:39 2008
New Revision: 4254

Modified:
    releases/1.6/user/src/com/google/gwt/user/client/ui/Accessibility.java
    releases/1.6/user/src/com/google/gwt/user/client/ui/CustomButton.java

Log:
For issue 3048, make toggle buttons (and other custom buttons) have the
"aria-pressed" WAI-ARIA state when they get toggled.

patch by: ajr
review by: rdayal (desk review)



Modified:  
releases/1.6/user/src/com/google/gwt/user/client/ui/Accessibility.java
==============================================================================
--- releases/1.6/user/src/com/google/gwt/user/client/ui/Accessibility.java      
 
(original)
+++ releases/1.6/user/src/com/google/gwt/user/client/ui/Accessibility.java      
 
Thu Dec  4 14:14:39 2008
@@ -59,6 +59,7 @@
    public static final String STATE_EXPANDED = "aria-expanded";
    public static final String STATE_LEVEL = "aria-level";
    public static final String STATE_HASPOPUP = "aria-haspopup";
+  public static final String STATE_PRESSED = "aria-pressed";

    private static final String ATTR_NAME_ROLE = "role";


Modified:  
releases/1.6/user/src/com/google/gwt/user/client/ui/CustomButton.java
==============================================================================
--- releases/1.6/user/src/com/google/gwt/user/client/ui/CustomButton.java       
 
(original)
+++ releases/1.6/user/src/com/google/gwt/user/client/ui/CustomButton.java       
 
Thu Dec  4 14:14:39 2008
@@ -681,6 +681,9 @@
        super.setEnabled(enabled);
        if (!enabled) {
          cleanupCaptureState();
+        Accessibility.removeState(getElement(),  
Accessibility.STATE_PRESSED);
+      } else {
+        setAriaPressed(getCurrentFace());
        }
      }
    }
@@ -837,6 +840,10 @@
        curFace = newFace;
        setCurrentFaceElement(newFace.getFace());
        addStyleDependentName(curFace.getName());
+
+      if (isEnabled()) {
+        setAriaPressed(newFace);
+      }
      }
    }

@@ -904,6 +911,12 @@
        default:
          throw new IllegalStateException(id + " is not a known face id.");
      }
+  }
+
+  private void setAriaPressed(Face newFace) {
+    boolean pressed = (newFace.getFaceID() & DOWN_ATTRIBUTE) == 1;
+    Accessibility.setState(getElement(), Accessibility.STATE_PRESSED,
+        pressed ? "true" : "false");
    }

    /**

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to