fyne icon indicating copy to clipboard operation
fyne copied to clipboard

Add tooltip

Open s77rt opened this issue 4 years ago • 18 comments

It would be nice to add a tooltip for certain widgets, mainly: a button and a label (or better, make it a part of the basewidget)

may be related: #155

s77rt avatar Dec 13 '20 09:12 s77rt

Tooltip is probably something that we could find a way to support on all widgets somehow. Good request. Not sure it should be in BaseWidget, however, probably something that widgets would opt-in to?

andydotxyz avatar Dec 14 '20 18:12 andydotxyz

As Fyne is a cross-platform toolkit, we need to consider how this would work across the supported platforms. Tooltips work well on desktop, where there is a mouse to hover over elements. However, they do not work on mobile and result in content not being accessible or discoverable.

If you are only targeting desktop then you can create a custom widget that displays a popup when the user hovers over it.

stuartmscott avatar Dec 14 '20 18:12 stuartmscott

Material seems to suggest on long-press for mobile. So we could do that using a hover event on desktop and perhaps code into mobile driver that long-press triggers tooltip. This certainly does need thought before we go ahead and build the functionality.

andydotxyz avatar Dec 15 '20 13:12 andydotxyz

In a recent call we discussed the idea of overlaying the ? icon onto top-right of widgets that have tooltips. This could be an interesting direction.

andydotxyz avatar Oct 27 '21 19:10 andydotxyz

MenuItems would also benefit from a tooltip.

d1ss0nanz avatar Jul 20 '22 08:07 d1ss0nanz

Perhaps, though it seems less important there as menu items are already textual in nature...

andydotxyz avatar Jul 23 '22 15:07 andydotxyz

Was this ever implemented?

syllith avatar Feb 10 '23 23:02 syllith

As this is still open, it hasn’t been implemented here yet. However, it is of course possible to create your own solution for custom widgets.

Jacalz avatar Feb 11 '23 07:02 Jacalz

I've been thinking about how tooltips could be designed into the Fyne API. I think a lot of apps would really benefit from them, mine included, but building out a custom solution is highly cumbersome.

I propose adding a new interface:

package widget

type ToolTippable interface {
    ToolTip() string
}

Widgets implement this interface if it is meaningful for them to have tool tips. This also allows app developers to easily extend builtin widgets to add or modify tooltips. Many builtin widgets may want to add a SetToolTip function to allow developers to set a tool tip without extending, or even just expose a ToolTip string property on the widget struct (though that naming conflicts with the interface function name.

How the tooltips are displayed is handled by the driver. On desktop a tool tip should be shown when the widget is hovered for a short time. This can happen even if the widget additionally implements Mouseable and has its own hover logic. On mobile, the tool tip should be shown on long press (secondary tap) IF the widget does NOT implement SecondaryTappable itself. Using long-press to show tooltips on mobile is the closest thing to a standard behavior according to Wikipedia. The responsibility is on app developers to not design a mobile interface that needs tool tips to be shown on widgets that are secondary tappable. Though there could also be a public function on the Driver interface ShowToolTipForWidget(w widget.ToolTippable) to allow developers to bind some other action to showing the tool tip, or build some kind of app tutorial workflow that programmatically shows tool tips for the widgets in a predefined order on first launch.

dweymouth avatar May 14 '23 17:05 dweymouth

Thanks for a good summary, but the statement "The responsibility is on app developers to not design a mobile interface that needs tool tips to be shown on widgets that are secondary tappable." Makes me quite nervous. I don't think we can put in app developers to avoid some features if they want to use others for certain platforms.

I'm not too sure why rendering them in the driver is right, I had considered making a Tooltip widget that standard widgets can make use of, or custom widgets could call directly...

andydotxyz avatar May 14 '23 18:05 andydotxyz

I had considered making a Tooltip widget that standard widgets can make use of, or custom widgets could call directly...

This could be a good idea too - even just an option on the existing PopUp widget for it to ignore all input (so MouseOut isn't immediately called if a widget tried to show a tooltip using PopUp) would make a custom tooltip solution a whole lot easier.

I guess showing tooltip on long press regardless if the widget does something else with long press could work on mobile, but it potentially leads to the scenario where two things are shown at once e.g. the tooltip plus a context menu that the widget displays on long press.

dweymouth avatar May 14 '23 20:05 dweymouth

I guess showing tooltip on long press regardless if the widget does something else with long press could work on mobile, but it potentially leads to the scenario where two things are shown at once e.g. the tooltip plus a context menu that the widget displays on long press.

Indeed, I don't think we can do both. Which is why the contributor discussions have leaned towards a small "tooltip button" attached to widgets on mobile when a tooltip is available. Like a small help option.

andydotxyz avatar May 15 '23 09:05 andydotxyz

需要一个这样的功能,有什么方法实现吗?

Mluocheng avatar Jun 09 '23 09:06 Mluocheng

Translated by Apple:

Such a function is needed. Is there any way to realise it?

andydotxyz avatar Jun 09 '23 16:06 andydotxyz