summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-27 10:30:00 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-27 10:30:00 +0100
commite92393d295bc4bb4c7b358ed67a95ccb696f7b8f (patch)
tree0f4caccd09833a1297497743477302d86fed856c
parent9b1f85fe575497c276551e2be7a8d5b45406745e (diff)
parent7b66806dd3afb77da2e7c681b342b40d392f6ccc (diff)
Merge pull request #67783 from EricEzaM/67715-input-event-action-as-text
Make InputEventAction as_text() return the text of the first valid event for the action.
-rw-r--r--core/input/input_event.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 74c0812f43..5a9ec74184 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -1499,7 +1499,18 @@ bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool p_exact
}
String InputEventAction::as_text() const {
- return vformat(RTR("Input Action %s was %s"), action, pressed ? "pressed" : "released");
+ const List<Ref<InputEvent>> *events = InputMap::get_singleton()->action_get_events(action);
+ if (!events) {
+ return String();
+ }
+
+ for (const Ref<InputEvent> &E : *events) {
+ if (E.is_valid()) {
+ return E->as_text();
+ }
+ }
+
+ return String();
}
String InputEventAction::to_string() {