How can I sink mouse events for options in a list box? I know the
browser generates the mouse events on option elements because I've
tried it manually, but I can't get it to work within gwt. Ultimately
I'm trying to generate tooltips for each item in a listbox.
Here's the code that doesn't work:
private class TopicsListBox extends ListBox implements EventListener {
...
protected void addTopic(TopicLink topic) {
addItem(topic.getName());
int lastIndex = getItemCount() - 1;
OptionElement option = getOptionElement(lastIndex);
com.google.gwt.user.client.Element castOption =
(com.google.gwt.user.client.Element) option.cast();
DOM.setEventListener(castOption, this);
DOM.sinkEvents(castOption, Event.MOUSEEVENTS);
}
public void onBrowserEvent(Event event) {
Element optionElement = event.getTarget();
switch (event.getTypeInt()) {
case Event.ONMOUSEOVER:
showTooltip(optionElement);
break;
case Event.ONMOUSEOUT:
cancelTooltip(optionElement);
break;
}
}
Can anyone give me some tips?
Thanks,
Peter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---