godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.54k stars 21.08k forks source link

Cannot drag and drop scene root (and sometimes other nodes too) from Scene Tree to Inspector field because holding mouse button doesn't lock the inspector as it does with other nodes #78001

Open hsandt opened 1 year ago

hsandt commented 1 year ago

Godot version

v4.0.2.stable.official [7a0977ce2]

System information

Linux Ubuntu 22.04 with Unity desktop

Issue description

Every time I try to assign the root node to an inspector Assign... field, I lose the node focus so the Inspector changes and I cannot complete the drag-and-drop action.

Godot 4 0 2 - Cannot drag root node (and sometimes other nodes too) without losing inspector focus

It also sometimes happened with other nodes: when focusing root node and trying to drag a child node; or even when focus some child node and trying to drag another child node.

Godot 4 0 2 - Cannot drag root node (and sometimes other nodes too) without losing inspector focus 2 (only in project)

Unfortunately, I could not reproduce the bug above in a fresh new project; it only happened in my full-fledged project.

=> So I'm removing this bug variant from this issue.

Steps to reproduce

  1. Open any MRP demo scene (there are several, but act the same).
  2. Focus on a non-root node
  3. Try to drag and drop the root node to any inspector field (there is often no real field to assign, but it doesn't matter; it's just to demonstrate inspector changing focus)

Expected: inspector should lock selection Actual: inspector focuses on root node

And you can even try the variants to drag other nodes too, in your own projects, which may trigger the bug as more complex setup seem to trigger it more often (even if a brand new scene!)

Minimal reproduction project

v4.0.2 - Drag and drop another node sometimes doesnt lock inspector.zip

Sauermann commented 1 year ago

Do you use X11 or Wayland? Can confirm issue on X11-Xfce v4.1.beta.custom_build [72b59325c].

Sch1nken commented 1 year ago

Can confirm the first (main) issue with the root-node being selected.

Second issue I could not replicate.

X11 (though this might only matter for the 2nd issue).

Tested on current master (a278c1b98a81738a35b96a933a6e6cf771f9ab2d).

hsandt commented 1 year ago

I use X11.

hsandt commented 8 months ago

Second issue I could not replicate.

Could not replicate second issue (root focused, child node dragged) on v4.2.1.stable.official [b09f793f5], and since my project configuration changed since (and I'm too lazy to investigate my Git history to find the exact spot where it happened), I'm removing this sub-issue. Even If it happened again, their causes may be different so I'd reopen a different issue anyway.

dbnicholson commented 1 week ago

It seems that the problem occurs here in the SceneTreeDock. When clicking on the root item, the click is outside of the child SceneTreeEditor's rectangle. Since tree_clicked isn't set, the selection handler ends up pushing the target node immediately as the new edited node. I added some debug prints that you can see in this screencast (sorry the mouse pointer doesn't show up).

godot-tree-selection.webm

Here's the text from clicking on 2 children of the root node and then the root node:

scene tree rect: [P: (0, 50), S: (393, 501)], local mouse pos: (125, 79), has point: yes
scene tree rect: [P: (0, 50), S: (393, 501)], local mouse pos: (119, 114), has point: yes
scene tree rect: [P: (0, 50), S: (393, 501)], local mouse pos: (81, 15), has point: no

The SceneTreeEditor rectangle starts at y=50 below the root node. It seems like the SceneTreeEditor rectangle is wrong, but maybe this isn't the right way to check if the mouse click was inside a particular child node.