Search code examples
gwtsmartgwt

Create tooltip after setting show hover is true


After setting setShowHover true, how do I create the tooltip? Right now it is a blank tooltip.

 ListGridField exportField = new IconField(FIELD_EXPORT, REDO_ICON.jpg, EXPORT_CUSTOM_GROUP_HANDLER);

exportField.setShowHover(true);

Tried exportField.setPrompt("a tooltip message");, but this did not give every single icon a tooltip when i mouse over it.

This a picture showing the tooltip is blank when i hover over the blue-pointer button, the message "a tooltip message" only appear when I hover over the very top blue-pointer button. I want it to show a tooltip for every blue-pointer button.

enter image description here


Solution

  • Use exportField.setHoverCustomizer() to show a customized prompt message.

    Try this one

        ListGrid grid = new ListGrid();
    
        grid.setCanHover(true);
        grid.setShowHover(true);
    
        ...
    
        exportField.setHoverCustomizer(new HoverCustomizer() {
    
            @Override
            public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                // you can customize the prompt and can get the values from current record also
                return "a tooltip message";
            }
        });