Tooltip for a MenuItem

There is no method available to set a tooltip for a MenuItem. There are methods in Menubar.addItem() but I’m looking one available in MenuItem class. Could this be added in the next release?

MenuBar has the method setTooltipText(MenuItem menuItem, String tooltipText)

Looking for the same in MenuItem itself like we’ve in other components

Any fix or workaround for this one ? In my case I create the menuItem first and then later add Tooltip which is not possible now as it is expecting both at the creation time itself

Hi,

Just make sure I understand your issue correctly. Why doesn’t the method setTooltipText(MenuItem menuItem, String tooltipText) in the MenuBar, as Olli mentioned, work for you?

If this method doesn’t fit your use case, I would suggest creating a new issue in the flow-components repo so we can evaluate adding this API to the component.

The problem is, I’ve an interface HasToolTip and is expecting methods like setTooltip. A fluentBuilder I’ve created is implemting this interface and soexpecting the tooltip in a different method like setToolTip so I’m looking something like that.

And for consistency purpose too, you can consider this way like all other components do

It you cannot rely on Vaadin Tooltip, you could use an Add-On like Tooltips4Vaadin. Which is End Of Life as I just see… But it works fine, I use it too.

Maybe implement it yourself into your fluentBilder and use some of Vaadin’s code:

    default Tooltip setTooltipText(String text) {
        var tooltip = Tooltip.getForElement(getElement());
        if (tooltip == null) {
            tooltip = Tooltip.forHasTooltip(this);
        }
        tooltip.setText(text);
        return tooltip;
    }