godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Allow for triggering GUI tooltips on focus #2584

Open h0lley opened 3 years ago

h0lley commented 3 years ago

Describe the project you are working on

A game with a settings screen where I want to describe certain settings in tooltips - and not just when the player is navigating via mouse.

Describe the problem or limitation you are having in your project

Currently, tooltips - which can be specified via the hint_tooltip property of Control - are only shown when hovering the node with your mouse cursor. This means that when navigating the GUI via keyboard or gamepad, they never appear. This is unfortunate since of course, when navigating with these devices, tooltips are no less relevant or useful.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I suggest to add a trigger_on_focus boolean property to the HInt section of Control. When enabled, the tooltip would also appear when the Control node receives focus, and disappear the moment it loses focus. This could take the project setting gui/timers/tooltip_delay_sec into account as well, personally I would want these on-focus tooltips to appear immediately though.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I believe no mock-ups are necessary as it is a very straight-forward proposal. Let me know if anything remains unclear.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Anyone who wants to give additional explanation to GUI options will consider making use of this feature. The alternative would be to implement your own tooltip system that also works with keyboard and gamepad navigation, but that would certainly require more than a few lines, and it would be a rather poor experience to have to implement something that the engine technically already provides.

Is there a reason why this should be core and not an add-on in the asset library?

As the existing tooltip system is already part of core, I think extending it directly makes most sense.

h0lley commented 3 years ago

As a bonus, it would be brilliant if on-focus tooltips would update their text in real-time when hint_tooltip is changed via script. Then, Slider nodes would become more powerful, as they could display their current value in the tooltip while the player moves the slider.

Concrete use-case: A setting to limit FPS. Slider is definitely a more appropriate choice thanLineEdit or PopupMenu here, but of course the player needs to understand what the current slider position means in terms of specific FPS.

Calinou commented 3 years ago

To be fair, I think you should implement your own tooltip system when you need complex features like:

The built-in tooltip system is designed for non-game applications like the editor. I wouldn't expect it to become a polished system for most games.

Concrete use-case: A setting to limit FPS. Slider is definitely a more appropriate choice thanLineEdit or PopupMenu here, but of course the player needs to understand what the current slider position means in terms of specific FPS.

You can use a Label node to display the chosen value next to the slider. Alternatively, you can use a SpinBox node.

h0lley commented 3 years ago

Right, I actually don't need any of those complex features though. :) I think I am proposing very basic functionality here: Making the existing tooltips system usable for keyboard and gamepad navigation. So it's hardly even a new feature - it's merely about no longer walling it off behind mouse exclusivity.

I guess I shouldn't have brought up the "as a bonus" application. I am aware that I could implement tooltips in all sorts of ways myself. However I think it's a waste to not leverage the existing system and that it's bloat to build my own.

I'm surprised about you disregarding tooltips for games. Are tooltips not a common feature used in games, and aren't there many very UI heavy games? With the current tooltips already being highly customizable with Godot's themes as well as providing the flexibility of having your own tooltip scenes through _make_custom_tooltip, I don't see how it would only be suitable to non-game applications.

Calinou commented 3 years ago

I'm surprised about you disregarding tooltips for games. Are tooltips not a common feature used in games, and aren't there many very UI heavy games?

The thing is that there's not "one true way" to do tooltips in games. Some games such as Minecraft will display tooltips for inventory items that move along the cursor. Some games will use "tooltips" displayed at the bottom of the screen to describe various options in a graphic settings menu.

Since tooltips are available in any Control node, we need to be careful about not bloating them.

h0lley commented 3 years ago

Makes sense. For non-floating tooltips, I agree that people should build their own thing. But I'd say the floating nature of tooltips is exactly what makes them so useful in most applications, and that's already implemented - ready to use... if your input device of choice is a mouse, that is.

Anyway, I am strictly sticking to the trigger on focus idea for this proposal now, and no extras. Tooltips would appear aligned to the bottom left corner of the Control node, I am thinking.

vvvvvvitor commented 10 months ago

Currently I also need this feature. Applications would also benefit from this being added, as many applications support keyboard alongside with the mouse. I have no idea why this feature only works when hovering.

Calinou commented 10 months ago

I have no idea why this feature only works when hovering.

This is standard behavior in applications (regardless of UI framework) and web browsers. Tooltips only appear on mouse hover, not on focus. If you see tooltips appearing on focus on a website, it's likely a CSS/JavaScript-based tooltip system being used on a specific website.

(This is the reason why using tooltips isn't recommended if a large portion of your audience is using a touch screen, as it's difficult to get tooltips to appear in this scenario.)

h0lley commented 10 months ago

I don't think they were suggesting that it's expected for tools and websites to have tooltips appear on focus.

when an user opts for keyboard or gamepad as their input device, or if those are the only available input devices, then there's no good reason for tooltips to no longer be available. With gamepad and keyboard navigation, too, tooltips are just as relevant and useful.

And when Godot users would merely need to tick a checkbox to enable tooltip support for gamepad or keyboard navigation instead of having to write an entire system then I don't see why that would't be a feature many projects would make use of.

the highly customizable tooltip feature is already fully built-in - merely the trigger options are limiting. pretty unfortunate.