Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocompletion for groups #8561

Closed
Cronos87 opened this issue Dec 1, 2023 · 5 comments
Closed

Add autocompletion for groups #8561

Cronos87 opened this issue Dec 1, 2023 · 5 comments

Comments

@Cronos87
Copy link

Cronos87 commented Dec 1, 2023

Describe the project you are working on

Any projects.

Describe the problem or limitation you are having in your project

When I add a node in a group, there is no autocompletion in the divers functions that uses groups.

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

When adding a node to a group, Godot will remember the names and save them in the .godot directory. By doing so, when using group methods, it will be able to autocomplete the group's name in the editor.

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

Autocompletion will be activated when the cursor is on the first parameter of the following methods:

  • Node.is_in_group()
  • Node.remove_from_group()
  • get_tree().get_nodes_in_group()

This is similar to Input.is_action_just_released() and other methods similar to this one. Godot will autocomplete with the input filled according to the project's settings.

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

I think it will be useful for everyone but I don't know if it can be done using an addon.

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

It would be lovely to have it in the core, as more developers can benefit from it.

@Mickeon
Copy link

Mickeon commented Dec 1, 2023

This will basically be "free" when global groups are implemented godotengine/godot#60965.

@Cronos87
Copy link
Author

Cronos87 commented Dec 1, 2023

I didn't know about this! It looks so much cleaner in this way! It could be a good complement to it.

Edit: Global groups have been merged godotengine/godot#60965 🎉.

@Mickeon
Copy link

Mickeon commented Dec 30, 2023

They have been merged, and as a bonus of the PR, "global" groups appear in the autocomplete suggestions for the Node and SceneTree's group methods. This proposal can be closed now.

@Cronos87
Copy link
Author

That works like a charm! I can close this proposal. Thanks a lot to the team!

@AThousandShips AThousandShips added this to the 4.3 milestone Dec 30, 2023
@matt08-prog
Copy link

matt08-prog commented Feb 24, 2025

I was wondering if the situation below is intended behavior [4.4.beta4.mono]. The list of global groups only appears in any of the group related methods for a node which is referenced using $ or % notation.

This problem seems related to godotengine/godot#99277. I can understand not wanting to give incorrect options for an unknown node in the case of node.get_node() or animations in the case of animation_player.play(). However, no matter what node you are calling is_in_group() on, providing the list of global groups shouldn't do any harm.

extends Node2D

@onready var test_node: Node = Node.new() as Node
@onready var control: Control = $Control
@onready var control_1: Control = %Control

func _ready() -> void:
	var this_node: Node = self as Node
	
	is_in_group("globalTestGroup") # Gives list of options
	get_tree().get_nodes_in_group("globalTestGroup") # Gives list of options
	control.is_in_group("globalTestGroup") # Gives list of options
	control_1.is_in_group("globalTestGroup") # Gives list of options

	self.is_in_group("globalTestGroup") # Doesn't give list of options
	test_node.is_in_group("globalTestGroup") # Doesn't give list of options
	this_node.is_in_group("globalTestGroup") # Doesn't give list of options
	Node.new().is_in_group("globalTestGroup") # Doesn't give list of options

I found a summary of the different autocomplete issues related to the Godot editor in godotengine/godot#86172. However, autocomplete for groups doesn't seem to fit any of those categories.

Edit: I made an Issue about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants