Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Any better way to show tooltips on menu items?

    I've seen some years ago there was a guy complaining for the lack of a way to show a tooltip/prompt for menu items.
    I made tooltips available on my menu items exploiting the ListGrid nature of menus. Here you are a raw example

    Code:
    final Menu menu = new Menu();
    menu.setCanHover(true);
    
    final ListGridField[] fields = menu.getFields();
    for (final ListGridField listGridField : fields) {
        listGridField.setShowHover(true);
        listGridField.setHoverCustomizer(new HoverCustomizer() {
            @Override
            public String hoverHTML(final Object value, final ListGridRecord record, final int rowNum,
                            final int colNum) {
                //return prompt text following proper logic i.e. accessing an array of menu items
                return myItems[rowNum].getPrompt(); 
            }
        });
    }
    //add items to menu
    I left here this example in the interest of other folks that need the same.
    Just wondering if there's a better way to achieve the same :-)

    It works on Smartgwt 3.0

    #2
    prompt on Menu and MenuItem

    Thanks a lot. Its a nice post.

    I want to show the prompt on Menu as well as MenuItem.

    Here is my code and working fine.

    Code:
        public class CustomMenu extends Menu {
        
            public CustomMenu (){
                setCanHover(true);
                setShowHoverComponents(true);
                setHoverCustomizer(new HoverCustomizer() {
        
                    @Override
                    public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
                        return "my custom title";
                    }
        
              }
        }
    Last edited by mchoudhary; 20 Jun 2014, 02:37. Reason: code formatting

    Comment

    Working...
    X