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

Prevent node rename shortcut from stealing focus from controls #93165

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

passivestar
Copy link
Contributor

Adds a check for controls that may react to Enter to prevent a conflict on macOS. Fixes #88102

Copy link
Member

@ajreckof ajreckof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something that has been a huge pain for quite some time. I haven't tested it but code looks good.

@akien-mga akien-mga requested a review from bruvzg June 25, 2024 12:07
@KoBeWi
Copy link
Member

KoBeWi commented Jun 29, 2024

The bug only occurs, because the default shortcut uses Enter. You can reproduce it on other systems if you manually assign Enter shortcut for renaming or other action. I wonder if other docks are affected too (considering non-default shortcuts).

I think instead of checking for Range you could add is_text_field() to EditorSpinSlider.

@passivestar
Copy link
Contributor Author

I wonder if other docks are affected too

Nope, no other dock reacts to enter like this

I think instead of checking for Range you could add is_text_field() to EditorSpinSlider

Seems reasonable

@passivestar passivestar requested review from a team as code owners June 29, 2024 18:40
@akien-mga akien-mga requested a review from KoBeWi July 9, 2024 08:43
Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes SceneTree shortcuts unusable when a Button is focused. Not sure if it's a problem though, as editor viewports can steal focus very easily so it shouldn't be noticeable.

@passivestar
Copy link
Contributor Author

Now only the rename shortcut is prevented if a button is focused

_tool_selected(TOOL_RENAME);
// Prevent renaming if a button is focused
// to avoid conflict with Enter shortcut on macOS
if (!focus_owner || !Object::cast_to<BaseButton>(focus_owner)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's... very specific 🙃
The issue only exists because of a default shortcut. Shortcuts are rebindable, so it doesn't solve all problems.
But eh, technically it fixes the linked issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is very specific and the code is not as pretty :). But previous code didn't make sense though... Blocking all shortcuts seems excessive, even if it's a rare encounter it doesn't feel good if nothing happens when you press a shortcut. If user rebinds to conflicting shortcuts it's a different story I think

@akien-mga akien-mga merged commit ef3443e into godotengine:master Jul 17, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

Scene tree steals focus from Inspector when pressing Enter on a focused SpinSlider
5 participants