Ok, I replaced the menu hover based on ListGrid's HoverCustomizer with a MouseMoveHandler that delays hovering for both active and inactive menu items.
For other folks with the same need I leave here a snippet with the complete solution I ended with:
Code:
private int currentEventRow = -1;
private Timer timer;
void assembleUI () {
...
menu.addMouseMoveHandler(new MouseMoveHandler() {
@Override
public void onMouseMove(final MouseMoveEvent event) {
final int eventRow = menu.getEventRow();
if (currentEventRow != eventRow) {
/*
* mouse moved to a different menu item
*/
currentEventRow = eventRow;
timer = new Timer() {
@Override
public void run() {
final String hoverHTML = getHoverHTML(eventRow);
if (hoverHTML != null) {
showHover(hoverHTML, menu.getHoverStyle(), menu.getHoverWidth());
}
timer = null;
}
};
timer.schedule(menu.getHoverDelay());
}
}
});
menu.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
cancelPreviousHover();
}
});
}
/**
* Cancel previous hover schedule.
*/
protected void cancelPreviousHover() {
if (timer != null) {
timer.cancel();
}
currentEventRow = -1;
Hover.hide();
}
private static native void showHover(final String contents, final String hoverStyle, final int hoverWidth)
/*-{
$wnd.isc.Hover.show(contents, { baseStyle: hoverStyle, width: hoverWidth, moveWithMouse: false });
}-*/;
Leave a comment: