Browse Source

Make InputEventAction as_text() return the text of the first valid event for the action.

Eric M 2 years ago
parent
commit
7b66806dd3
1 changed files with 12 additions and 1 deletions
  1. 12 1
      core/input/input_event.cpp

+ 12 - 1
core/input/input_event.cpp

@@ -1408,7 +1408,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() {