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

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

Open
KoBeWi opened this issue Sep 6, 2018 · 10 comments · May be fixed by #79517
Open

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

KoBeWi opened this issue Sep 6, 2018 · 10 comments · May be fixed by #79517

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Sep 6, 2018

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
Copy link
Contributor

Piet-G commented Sep 6, 2018

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

@KoBeWi
Copy link
Member Author

KoBeWi commented Sep 6, 2018

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
Copy link
Member Author

KoBeWi commented Nov 27, 2019

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 KoBeWi closed this as completed Nov 27, 2019
@KoBeWi KoBeWi added this to the 3.2 milestone Nov 27, 2019
@KoBeWi
Copy link
Member Author

KoBeWi commented Jan 12, 2020

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
Copy link

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

@KoBeWi
Copy link
Member Author

KoBeWi commented Dec 2, 2022

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

This comment was marked as off-topic.

@AThousandShips
Copy link
Member

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

@KoBeWi KoBeWi linked a pull request Jul 15, 2023 that will close this issue
@KoBeWi
Copy link
Member Author

KoBeWi commented Jul 15, 2023

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

@JorensM
Copy link

JorensM commented Apr 21, 2024

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

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

Successfully merging a pull request may close this issue.

8 participants