Is it possible to add mouseover on a Hyperlink? If so, how?
I have several Hyperlinks and would like to provide a mouse over text
(like a small tool-tip) for the hyperlink.
Thanks.
Joster
You would put a Hyperlink into a FocusPanel and the focus panel will
receive the mouse events you are looking for and you can then do
whatever you want with them.
If you find yourself needing this sort of thing often putting together
a simple composite of the two will make your life easier!
FocusPanel docs here:
http://code.google.com/webtoolkit/documentation/com.google.gwt.user.client.ui.FocusPanel.html
On Sep 11, 10:39 pm, "Les Harris" <orphean...@gmail.com> wrote:
> The Hyperlink class unfortunately does not appear to support that on
> its own. However, I believe that you should look into FocusPanel.
>
> You would put a Hyperlink into a FocusPanel and the focus panel will
> receive the mouse events you are looking for and you can then do
> whatever you want with them.
>
> If you find yourself needing this sort of thing often putting together
> a simple composite of the two will make your life easier!
>
> FocusPanel docs here:http://code.google.com/webtoolkit/documentation/com.google.gwt.user.c...
other solution requires just few changes in Hyperlink extended class:
public class MyHyperlink extends Hyperlink {
MyHyperlink(String text, String targetHistoryToken) {
super(text, targetHistoryToken);
sinkEvents(Event.MOUSEEVENTS);
}
public void onBrowserEvent(Event event) {
if (DOM.eventGetType(event) == Event.ONMOUSEOVER) {
showTips();
}
super.onBrowserEvent(event);
}
private void showTips() {
if (tip == null) {
tip = new PopupPanel(true);
tip.setWidget(new Label("Clicks me! click me!"));
tip.setStyleName("gwt-DialogBox");
}
tip.setPopupPosition(getAbsoluteLeft() + 5, getAbsoluteTop() + 5);
tip.show();
}
private PopupPanel tip;
}
RootPanel rootPanel = RootPanel.get();
Hyperlink hyperlink = new MyHyperlink("New Hyperlink", "some history
token");
rootPanel.add(hyperlink, 5, 5);
regards,
Peter