godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.13k stars 91 forks source link

Add something akin to an `item_focused(index : int)` signal for individual items in an `ItemList` node #10025

Open abmarnie opened 3 months ago

abmarnie commented 3 months ago

Describe the project you are working on

A 2D sim game with quest log and inventory systems

Describe the problem or limitation you are having in your project

Using ItemList for quest logs and inventories doesn't allow for as nice polish as I'd like. I want to add sound effects when an item is focused over (but not selected) via mouse or gamepad controls.

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

ItemList class would have it's own signal, which gets emitted when an item is "focused". "Focus" should work as you'd expect on both gamepad and mouse + keyboard.

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

my_item_list.item_focused.connect(func(index : int) -> void: my_sound.play())

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

To the best of my ability, no. The closest useful thing I could find that would help solve this issue is maybe doing crazy stuff with my_item_list.get_item_at_position(my_pos) inside a _process call, and it would be troublesome getting it to work with both mouse and gamepad. You could instantiate new Button under a vertical ScrollContainer, but then you lose out on the search functionality of ItemList.

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

This greatly improves the ItemList experience right out of the box. It is a nice node since it comes with searching.

AThousandShips commented 3 months ago

As far as I can tell navigating with keyboard to an item selects it, the signal for activating it is separate, so this would probably break compatibility if the suggestion is to make it no longer send the item_selected signal when using keyboard

abmarnie commented 3 months ago

Truthfully, I only tested with mouse. I guess what I really want is an item_hovered signal?

AThousandShips commented 3 months ago

Probably yes, there's no current distinction between "focus" and "selected", there is one for hovering though, but hover is not the same as focus

surreal6 commented 1 month ago

Hi. I am working in an accesible UI with text to speech and head selection (gaze pointer for XR interfaces) and found that there is no mouse_entered and mouse_exited signals for optionButton items. There is a item_focused, so i can implement text to speech when using key input, but i need a item_mouse_entered to detect gaze selection of each item, as it works by moving the mouse over the ui.

I already have boolean inputs. integer and float sliders, and buttons working with both focus and mouse, godot just lack of this signal to have a complete set of ui interactions.

So, +1 to add "item_hovered", or "item_mouse_entered" and "item_mouse_exited" signals, This would be a great feature to complete the ui set and to help build accesible interfaces