GWT 508 - Alternative text on gwt-tree expand/collapse image

164 views
Skip to first unread message

M

unread,
Sep 7, 2010, 10:50:23 AM9/7/10
to Google Web Toolkit

I am trying to resolve some 508 compliance issues. I have a gwt-tree
and I need to set the alt-text for the "expand/collapse" images used
on the tree. Unlike images I have set on html pages I am using, I am
unclear where I can set this in my code.

Any suggestions would be appreaciated.

TIA,

Mike

andrew

unread,
Aug 15, 2011, 1:13:26 PM8/15/11
to google-we...@googlegroups.com
Running into the same kinds of issues almost a year after this post (using GWT 2.0.4)...
Need to set alt text and need to discern both tree selection and hierarchy with CSS turned off.

This can be made more elegant but here is the strategy (some GWT Tree assumptions are made here)...
We are adding and OpenHandler and CloseHandler to the Tree.
Each handler checks if the TreeItem has children then it has an expand or collapse (+/-) child image (may want to consider whether or not you have leaf images).

For each TreeItem with children,  item, whose <img> alt or title attributes you want to set, access its <img> tags:
NodeList<com.google.gwt.dom.client.Element> imgs =  item.getElement().getElementsByTagName("img");

access the first Element in this set because this is the +/- img and set the attributes you want:
com.google.gwt.dom.client.Element elem = imgs.getItem(0);
elem.setAttribute("alt", "...");
elem.setAttribute("title", "...");

Our selected strategy is to append to the beginning of the selected TreeItem's text a selected character (ex. right-facing triangle).

Still working on a solution to showing tree depth with CSS off.
Reply all
Reply to author
Forward
0 new messages