godotengine / godot

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

Editor will auto-focus on script when error happens, which causes silly things to appear #21812

Open KoBeWi opened 6 years ago

KoBeWi commented 6 years ago

Consider this: you have script which (partially) might look like this:

if player.position.x > position.x and player.health < 8:
    do_something()

This is, say, enemy script. You now run your scene, go right and press Z to jump over enemy. BUT! Turns out player doesn't have health property. Your script now looks like this:

zzzzzzzzzzzzzzzzzzzif player.position.x > position.x and player.health < 8:
    do_something()

That's because Godot complained about the lack of property and tried to be useful by focusing your editor on that particular line. It didn't predict though that you are in the middle of jumping, still holding jump key (Z), so when your focus jumps on script editor your Z will now appear in the script. Bonus if you have two monitors and don't immediately notice the issue. Believe me, it happened enough times for me to create this issue >.>

Minimal reproduction project: TestProject.zip Just run it and hold Z.

Piet-G commented 6 years ago

I wonder what would be better behavior though?, focusing on the script is really useful.

KoBeWi commented 6 years ago

Yeah, it could focus, but not in a way that makes you type whatever character you happen to have pressed. Dunno, maybe set the input to "disabled" state until you release all keys or something.

KoBeWi commented 5 years ago

No idea when it happened and if it's intended, but the editor no longer focuses on error. I mean, it still jumps to relevant line, but the game keeps the focus, so the unintended editor input no longer happens. Closing as fixed then ¯\_(⊙ʖ⊙)

KoBeWi commented 4 years ago

Reopening. The focus behavior I mentioned in the previous comment happens randomly and seems to be uncommon (not sure what happened during my previous tests). It might be a bug actually xd

So the original problem still exists.

CarpenterBlue commented 2 years ago

I would suggest that the script editor gets focused after user lifts hands of the keyboard. It is SUPER annoying.

KoBeWi commented 2 years ago

No, imagine an error happens when you hold a button. You won't notice it until you release the button. Also what happens between error and releasing? Does the game freeze? How do you even detect release if a window is not focused?

I already proposed a solution before - block input (at least in script editor) when editor gets focused, until the user releases all buttons.

TheHorscht commented 1 year ago

Is this still on the radar? Am I the only one bothered by this?

AThousandShips commented 1 year ago

@TheHorscht Please don't bump issues without contributing significant new information. Use the :+1: reaction button on the first post instead.

KoBeWi commented 1 year ago

I opened a PR with a fix, but it's blocked by another issue.

JorensM commented 7 months ago

How about highlighting the relevant line in the editor without focusing the text cursor? I don't know if it's possible to highlight a line though in Godot