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

The hiding of Script Editor when selecting node in Scene Tree #39539

Closed
KoBeWi opened this issue Jun 14, 2020 · 25 comments · Fixed by #61162
Closed

The hiding of Script Editor when selecting node in Scene Tree #39539

KoBeWi opened this issue Jun 14, 2020 · 25 comments · Fixed by #61162

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Jun 14, 2020

I just discovered a function called can_lose_focus_on_node_selection() in ScriptEditorPlugin class. It returns false for VisualScript editor and true for other script editors. When it's true, clicking a node in Scene Tree will change the viewport to this node's native (i.e. 2D or 3D). Before the function was introduced, Godot would switch away from Script Editor unconditionally.

Now, I've seen an issue where this behavior was labeled as a bug: #14862
There's also #33704, which is related
EDIT: Another old issue: #20676 (this time enhancement)

The question is: is this behavior useful? Many users will probably agree that if you are in the Script Editor, you want to click nodes in Scene Tree without hiding the Script Editor (some people want e.g. to check them in the inspector). Personally I don't see why would we want to switch on click, other than it being maybe faster than clicking the 2D/3D button on the top.

I opened this issue to discuss this problem. We could either:

  1. leave the behavior as it is (which means Selecting a node change editor to the editor where the node has a "physical" representation #14862 should be closed and Drag & Drop node to scripts sometimes handles incorrectly #33704 fixed properly)
  2. remove this behavior (would close both of these issues, and probably some others)
  3. make it optional editor setting (should be easy, by reading the setting in the can_lose_focus_on_node_selection() method)
  4. change it to switch double-click or something similar

Any thoughts?

@PostPollux
Copy link

I prefer option 2. For me this behaviour was always counter-intuitive and it happens quite frequently. It's maybe one click more, if we want to change the view, but it's a logical click that makes sense, whereas the current behaviour can be quite irritating, because in a lot of scenarios it's just doing additional stuff you did not intent and you find your self fighting with it and having to go back manualy again.

It happend to me both, when I wanted to look at a property or property path of a node or when I tried to drag and drop the node path into the text editor.

I don't think there should be an option for it, as I don't like bloated editor settings. For me the proposed solution ( in #14862) of using a doubleclick for the current behaviour would make more sense.

Fixing this behaviour would be very appreciated. Thanks!

@KoBeWi
Copy link
Member Author

KoBeWi commented Jun 14, 2020

Ah yes, I forgot that there's a 4th option actually.

@PostPollux
Copy link

Then I'm for option 4!

@Calinou
Copy link
Member

Calinou commented Jun 15, 2020

I think using double-click for this makes the most sense too.

@Zylann
Copy link
Contributor

Zylann commented Jun 15, 2020

Isnt double-click triggering node rename?
Also double-click on the node icon teleports the camera to it. I didn't even know.
More stuff on double-click already than I thought^^

@name-here
Copy link

Could give rename a default keybinding and make double clicking the node show it in the scene in one way or another. Also, double clicking on the icon to teleport the camera to it is pretty unintuitive and hard to find if you don't know about it already.

@Calinou
Copy link
Member

Calinou commented Jun 15, 2020

Could give rename a default keybinding

This is done by #38201, but it seems some users still prefer double-clicking nodes to rename them instead of pressing F2 (perhaps because they don't know about this shortcut in general).

@follower
Copy link
Contributor

It may be worth keeping in mind that F2 to rename has very DOS/Windows-centric origins...

Assuming that people using Macs keep the default keyboard settings, F2 will be brightening their screen unless they also hold the fn keys.

I'm definitely in favour of not unintentionally switching away from the Script Editor though. :)

@EricEzaM
Copy link
Contributor

I'm for option 2. If you are in the script editor and you click on a node, I think the behaviour should be to show that node in the inspector and stay in the script editor, because if you are in the script editor... well... you are working on scripts, and thats what you want to do. If you want to see the 2D/3D representation, just click on the 2D/3D buttons at the top to switch. I dont think there should be a shortcut to get there in the scene tree, apart from maybe a right click > go to node in viewport or similar.

@eon-s
Copy link
Contributor

eon-s commented Jul 15, 2020

Maybe Shift+Click to avoid changing context?

@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 15, 2020

More like Alt+Click, Shift is used for multiselecting. But sounds like a good option.

@Calinou
Copy link
Member

Calinou commented Jul 15, 2020

I think not changing context should be the default. Changing context should require a modifier like Alt instead.

@jordanlis
Copy link

jordanlis commented Oct 7, 2021

one other related issue is that when you switch from 2D to scripting panel, the scene tree is not hidden by default or according to the user's preferences.
Let say you hide the nodes panel / scene tree the first time you access to the scripting panel, then when you do again the same action, the scene tree won't be hidden and you will have to click on it again.

@KoBeWi
Copy link
Member Author

KoBeWi commented Dec 21, 2021

After #55761 was merged, you can now hold Alt while clicking in the scene tree to prevent the viewport from switching. This resolves the issue, but just isn't very discoverable.

@EricEzaM
Copy link
Contributor

@KoBeWi is #40438 obsolete then?

@KoBeWi
Copy link
Member Author

KoBeWi commented Dec 23, 2021

Probably yes. As for the issue, I recently seen someone mention an alternative solution. Instead of using a random modifier, the editor could switch only after release/long press of the button and don't switch when you drag. If that could work then it would be better, as there is no use in only selecting a node without focusing; you always want to drag it.

@Zireael07
Copy link
Contributor

and don't switch when you drag

Pretty please :)

@eon-s
Copy link
Contributor

eon-s commented Dec 23, 2021

Maybe a pin/lock can help too (animationplayer has one, for example), for script editor and 2d/3d viewports, sometimes you just want to see an item in the inspector, drag and drop, etc. without changing the main view.

@akien-mga akien-mga modified the milestones: 4.0, 3.5 May 23, 2022
@differenceclouds
Copy link

differenceclouds commented Oct 14, 2022

I would really like to stay on the script I'm editing when I hit the Play button. I really have no clue why it would switch to a different view.
Edit: it will stay on the open script if you don't have any node selected. This isn't really a solution however.

@nikolayhristov-elfshock

After #55761 was merged, you can now hold Alt while clicking in the scene tree to prevent the viewport from switching. This resolves the issue, but just isn't very discoverable.

Does not work on macOS on 4.2 beta

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 19, 2023

It was removed. Editor will automatically detect whether you are dragging or not and switch if not.

@nikolayhristov-elfshock

It was removed. Editor will automatically detect whether you are dragging or not and switch if not.

my bad, but the issue still persists, if I want to change different inspector values while using the viewport, since in a 3D view the viewport disables the 2D and when the editor toggles you basically get an empty screen

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 19, 2023

Can you post some video of the issue?

@nikolayhristov-elfshock

Sure, some explanation - in the video I'm testing if adjusting the scale would work for my indicator, before writing the code and this is when I hit this annoying issue

Screen.Recording.2023-10-20.at.0.28.36.mp4

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 19, 2023

That's another issue, see godotengine/godot-proposals#8150

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