godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Add keybind to select parent of current node #9903

Open BuyMyMojo opened 5 months ago

BuyMyMojo commented 5 months ago

Describe the project you are working on

Games

Describe the problem or limitation you are having in your project

When instancing a new scene in the tree it will select the new node as the current one which is useful for quickly moving the object after creating it but then needing to click the parent node before instancing a new node to stop the creation of a nesting doll is a pain.

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

A simple keybind to select the parent of the currently selected node without needing to clack back into the scene tree (Pressing the left arrow key does not fill this requirement)

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

root node/parent selected CTRL + A/CTRL + SHIFT + A to spawn a new node Move selected node [Keybind} to reselect parent/root node repeat

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

@tool
extends Node

var instant_press: bool = true

func _process(_delta):
    if is_keybind_pressed() && instant_press == true:
        var selected_nodes: Array[Node] = EditorInterface.get_selection().get_selected_nodes()

        if selected_nodes.size() == 1:
            var parent: Node = selected_nodes[0].get_parent()
            EditorInterface.get_selection().clear()
            await get_tree().create_timer(0.05).timeout
            EditorInterface.edit_node(parent)

        instant_press = false
    elif is_keybind_pressed() == false && instant_press == false:
        instant_press = true

func is_keybind_pressed() -> bool:
    return Input.is_key_pressed(KEY_CTRL) && Input.is_key_pressed(KEY_J)

add this as an autoload to set CTRL + J to the functionality in a kind of bodjed way using a timer to stop the deselect from happening after the new selection for some reason

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

A single useful keybind to add a quick boost to level creation/blockout time seems like a good little feature to be in the engine itself as opposed to an addon people need to seek out

AThousandShips commented 5 months ago

When you have the tree actively selected you just press left to go to the parent, but it only works when the tree is active

BuyMyMojo commented 5 months ago

When you have the tree actively selected you just press left to go to the parent, but it only works when the tree is active

I did mention this in the issue|

without needing to clack back into the scene tree (Pressing the left arrow key does not fill this requirement)

BuyMyMojo commented 5 months ago

https://github.com/godotengine/godot-proposals/assets/46948241/0dc39d41-c7b1-42f9-bd1b-742b9935903f

I forgot to provide a quick demo of the script running, here it is