Skip to content

Allow numpad comma , to be used for 3D Blender-Style Transforms #107441

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

Merged

Conversation

ryevdokimov
Copy link
Contributor

Fixes: #107432

@ryevdokimov ryevdokimov requested a review from a team as a code owner June 12, 2025 09:02
@Chaosus Chaosus added this to the 4.5 milestone Jun 12, 2025
@AThousandShips AThousandShips added cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release labels Jun 12, 2025
@@ -2283,7 +2283,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else if (unicode == '-') {
_edit.numeric_negate = !_edit.numeric_negate;
update_transform_numeric();
} else if (unicode == '.') {
} else if (unicode == '.' || unicode == ',') {
Copy link
Member

Choose a reason for hiding this comment

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

The comment above says:

// Use the Unicode value because we care about the text, not the actual keycode.
// This ensures numbers work consistently across different keyboard language layouts.

But I think that's a misunderstanding of the API, you shoudl use get_keycode() instead of get_physical_keycode() to get the keycode from the user's keyboard mapping.

And then for period specifically, using get_physical_keycode() to check that it's the en_US KP_PERIOD should also work I expect.

Copy link
Contributor Author

@ryevdokimov ryevdokimov Jun 12, 2025

Choose a reason for hiding this comment

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

Makes sense, I agree that using the main keyboard comma too might be overdoing it, since some software dedicates some specific functionality to it.

@akien-mga akien-mga removed the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Jun 12, 2025
@ryevdokimov ryevdokimov force-pushed the blender-comma-transform branch from f981b61 to cc3246b Compare June 12, 2025 10:44
if (unicode >= '0' && unicode <= '9') {
uint32_t value = uint32_t(unicode - Key::KEY_0);

if ((keycode >= Key::KEY_0 && keycode <= Key::KEY_9) || (keycode >= Key::KP_0 && keycode <= Key::KP_9)) {
Copy link
Member

Choose a reason for hiding this comment

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

You might want to keep using physical keycode here, at least for the main numbers above QWERTYUIOP.

On a French AZERTY keyboard, the numbers are in the same place but they're secondary keys, the first keys are accented characters and other symbols, you have to press "Shift+1" to get "1" (technically "Shift+&"): https://en.wikipedia.org/wiki/AZERTY

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Part of the fun of making PRs is learning about stuff like this 😂

Thanks for the review.

@@ -2283,11 +2289,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else if (unicode == '-') {
Copy link
Member

Choose a reason for hiding this comment

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

You can use KEY_MINUS and KEY_KP_MINUS here (non-physical), and remove unicode.

@@ -2283,11 +2289,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
} else if (unicode == '-') {
_edit.numeric_negate = !_edit.numeric_negate;
update_transform_numeric();
} else if (unicode == '.') {
} else if (keycode == Key::PERIOD || physical_keycode == Key::KP_PERIOD) {
Copy link
Member

Choose a reason for hiding this comment

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

I guess the use of physical for KP_PERIOD might warrant a comment.

@ryevdokimov ryevdokimov force-pushed the blender-comma-transform branch 2 times, most recently from f1567c7 to ecbffff Compare June 12, 2025 20:39
@ryevdokimov
Copy link
Contributor Author

Hmm, I was able to dig up a couple different layout keyboards I had laying around and found a few issues. Will investigate more.

@ryevdokimov
Copy link
Contributor Author

Nevermind, I think it's fine. Should be good.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@ryevdokimov ryevdokimov force-pushed the blender-comma-transform branch from ecbffff to 6f48795 Compare June 13, 2025 09:25
@ryevdokimov
Copy link
Contributor Author

Accidently put the main keyboard comma back, so removed that. Now it should be good for real.

@akien-mga akien-mga changed the title Allow comma , to be used for 3D Blender-Style Transforms Allow numpad comma , to be used for 3D Blender-Style Transforms Jun 13, 2025
@akien-mga akien-mga merged commit 7e385da into godotengine:master Jun 13, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@ryevdokimov ryevdokimov deleted the blender-comma-transform branch June 13, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release topic:editor topic:input topic:3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blender-style 3D transform tools don't recognize the numpad comma (,)
4 participants