Skip to content

Commit 7e385da

Browse files
committed
Merge pull request godotengine#107441 from ryevdokimov/blender-comma-transform
Allow numpad comma `,` to be used for 3D Blender-Style Transforms
2 parents 7f925a1 + 6f48795 commit 7e385da

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

editor/plugins/node_3d_editor_plugin.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,27 +2270,36 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
22702270
if (_edit.instant) {
22712271
// In a Blender-style transform, numbers set the magnitude of the transform.
22722272
// E.g. pressing g4.5x means "translate 4.5 units along the X axis".
2273-
// Use the Unicode value because we care about the text, not the actual keycode.
2274-
// This ensures numbers work consistently across different keyboard language layouts.
22752273
bool processed = true;
2276-
Key key = k->get_physical_keycode();
2277-
char32_t unicode = k->get_unicode();
2278-
if (unicode >= '0' && unicode <= '9') {
2279-
uint32_t value = uint32_t(unicode - Key::KEY_0);
2274+
Key keycode = k->get_keycode();
2275+
Key physical_keycode = k->get_physical_keycode();
2276+
2277+
// Use physical keycode for main keyboard numbers (for non-QWERTY layouts like AZERTY)
2278+
// but regular keycode for numpad numbers.
2279+
if ((physical_keycode >= Key::KEY_0 && physical_keycode <= Key::KEY_9) || (keycode >= Key::KP_0 && keycode <= Key::KP_9)) {
2280+
uint32_t value;
2281+
if (physical_keycode >= Key::KEY_0 && physical_keycode <= Key::KEY_9) {
2282+
value = uint32_t(physical_keycode - Key::KEY_0);
2283+
} else {
2284+
value = uint32_t(keycode - Key::KP_0);
2285+
}
2286+
22802287
if (_edit.numeric_next_decimal < 0) {
22812288
_edit.numeric_input = _edit.numeric_input + value * Math::pow(10.0, _edit.numeric_next_decimal--);
22822289
} else {
22832290
_edit.numeric_input = _edit.numeric_input * 10 + value;
22842291
}
22852292
update_transform_numeric();
2286-
} else if (unicode == '-') {
2293+
} else if (keycode == Key::MINUS || keycode == Key::KP_SUBTRACT) {
22872294
_edit.numeric_negate = !_edit.numeric_negate;
22882295
update_transform_numeric();
2289-
} else if (unicode == '.') {
2296+
} else if (keycode == Key::PERIOD || physical_keycode == Key::KP_PERIOD) {
2297+
// Use physical keycode for KP_PERIOD to ensure numpad period works consistently
2298+
// across different keyboard layouts (like nordic keyboards).
22902299
if (_edit.numeric_next_decimal == 0) {
22912300
_edit.numeric_next_decimal = -1;
22922301
}
2293-
} else if (key == Key::ENTER || key == Key::KP_ENTER || key == Key::SPACE) {
2302+
} else if (keycode == Key::ENTER || keycode == Key::KP_ENTER || keycode == Key::SPACE) {
22942303
commit_transform();
22952304
} else {
22962305
processed = false;

0 commit comments

Comments
 (0)