mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 05:39:58 +00:00
Merge pull request #113553 from bruvzg/no_phy
Do not show `Physical` in the special key names.
This commit is contained in:
commit
877b113afa
2 changed files with 27 additions and 7 deletions
|
|
@ -475,7 +475,10 @@ String InputEventKey::as_text() const {
|
|||
} else if (keycode != Key::NONE) {
|
||||
kc = keycode_get_string(keycode);
|
||||
} else if (physical_keycode != Key::NONE) {
|
||||
kc = keycode_get_string(physical_keycode) + " - " + RTR("Physical");
|
||||
kc = keycode_get_string(physical_keycode);
|
||||
if ((physical_keycode & Key::SPECIAL) != Key::SPECIAL) {
|
||||
kc += " - " + RTR("Physical");
|
||||
}
|
||||
} else {
|
||||
kc = "(" + RTR("unset") + ")";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,26 +123,43 @@ TEST_CASE("[InputEventKey] Key correctly converts itself to text") {
|
|||
|
||||
// Key is None WITH a physical key AND modifiers.
|
||||
none_key.set_physical_keycode(Key::ENTER);
|
||||
CHECK(none_key.as_text() == "Ctrl+Enter - Physical");
|
||||
CHECK(none_key.as_text() == "Ctrl+Enter");
|
||||
|
||||
none_key.set_physical_keycode(Key::W);
|
||||
CHECK(none_key.as_text() == "Ctrl+W - Physical");
|
||||
|
||||
// Key is None WITH a physical key AND multiple modifiers, checks for correct ordering.
|
||||
none_key.set_physical_keycode(Key::ENTER);
|
||||
none_key.set_alt_pressed(true);
|
||||
none_key.set_shift_pressed(true);
|
||||
#ifdef MACOS_ENABLED
|
||||
CHECK(none_key.as_text() != "Ctrl+Shift+Option+Enter - Physical");
|
||||
CHECK(none_key.as_text() == "Ctrl+Option+Shift+Enter - Physical");
|
||||
CHECK(none_key.as_text() != "Ctrl+Shift+Option+Enter");
|
||||
CHECK(none_key.as_text() == "Ctrl+Option+Shift+Enter");
|
||||
#else
|
||||
CHECK(none_key.as_text() != "Ctrl+Shift+Alt+Enter - Physical");
|
||||
CHECK(none_key.as_text() == "Ctrl+Alt+Shift+Enter - Physical");
|
||||
CHECK(none_key.as_text() != "Ctrl+Shift+Alt+Enter");
|
||||
CHECK(none_key.as_text() == "Ctrl+Alt+Shift+Enter");
|
||||
#endif
|
||||
none_key.set_physical_keycode(Key::W);
|
||||
#ifdef MACOS_ENABLED
|
||||
CHECK(none_key.as_text() != "Ctrl+Shift+Option+W - Physical");
|
||||
CHECK(none_key.as_text() == "Ctrl+Option+Shift+W - Physical");
|
||||
#else
|
||||
CHECK(none_key.as_text() != "Ctrl+Shift+Alt+W - Physical");
|
||||
CHECK(none_key.as_text() == "Ctrl+Alt+Shift+W - Physical");
|
||||
#endif
|
||||
|
||||
InputEventKey none_key2;
|
||||
|
||||
// Key is None without modifiers with a physical key.
|
||||
none_key2.set_keycode(Key::NONE);
|
||||
none_key2.set_physical_keycode(Key::W);
|
||||
|
||||
CHECK(none_key2.as_text() == "W - Physical");
|
||||
|
||||
none_key2.set_keycode(Key::NONE);
|
||||
none_key2.set_physical_keycode(Key::ENTER);
|
||||
|
||||
CHECK(none_key2.as_text() == "Enter - Physical");
|
||||
CHECK(none_key2.as_text() == "Enter");
|
||||
|
||||
InputEventKey key;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue