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

ESC key does not work sometimes in the script editor. #70049

Closed
Torguen opened this issue Dec 14, 2022 · 4 comments · Fixed by #79079
Closed

ESC key does not work sometimes in the script editor. #70049

Torguen opened this issue Dec 14, 2022 · 4 comments · Fixed by #79079

Comments

@Torguen
Copy link

Torguen commented Dec 14, 2022

Godot version

v3.5.1.stable.official [6fed1ff]

System information

w10 64

Issue description

Watch the video:
I want to replace a word and open the replacer.
I immediately decide that I won't replace it in the end and close the replacer by pressing ESC.
Again I reopen the replacer determined to replace.
I write the new word and click on "Replace all".
Now I press ESC but ESC doesn't close the replacer, ESC doesn't work now and I have to close the replacer using the mouse.

Conclusion:
The ESC key will not close the replacer when you click the "Replace All" button.

2022-12-14.10-26-52.mp4

Steps to reproduce

Watch the video and the description.

Minimal reproduction project

...

@DissonantVoid
Copy link
Contributor

this is technically not a bug, as you can see in this function inside code_editor.cpp which handles the input for the find panel
g
as you expect when pressing the ESC key _hide_bar() is called.
the problem is that this function checks for unhandled input which means that an input events will be handled by the UI child that is focused first and up the tree from there.
this is where the issue happens, when you press replace or replace_all (any button that is a part of the panel) the pressed button becomes focused meaning that it gets to handle any input event, and since the button actually handles keyboard events and doesn't ignore them (unlike the line edit where you type what to replace for example). the event doesn't propagate up to the FindReplaceBar object so it doesn't get handled

Please keep in mind that this is just my somewhat-educated guess, I don't know too much about how the engine works internally and I could be wrong. one thing that really confused me is that for an event to be handled, you must call accept_event() in the function where you handle the input, this way it doesn't propagate further into the next _unhandled_event() function. but that is not the case in base_button.cpp
e
so either I overlooked something, or the _gui_input() function automatically marks events as handled? I'm not so sure..

regardless, this isn't really a bug but rather a design issue.
and to fix it I guess we can either do it the hacky way by connecting the child buttons pressed signal to the panel and listen for the ESC button
or we can.. actually I don't know and I'm running out of time. I hope someone can come up with something from here.
best of luck!

@stmSi
Copy link
Contributor

stmSi commented Dec 24, 2022

creating new _gui_input() for Replace All button to handle ESC key is too much code for little to gain.

So I think may be closing/hiding the Bar after pressing the Replace All button is more convenient.

@Torguen
Copy link
Author

Torguen commented Dec 24, 2022

I wouldn't approve of that solution because you don't know if the user wants to do more replacements.

A future bug would be "replace window closes when I do a replace".

I think the replacement window needs to be closed by the user.

@stmSi
Copy link
Contributor

stmSi commented Dec 24, 2022

ya... you are right.. I am changing it.

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