浏览代码

Fixed shortcuts not working with InputEventActions

Max 7 年之前
父节点
当前提交
c2be1a75a0
共有 2 个文件被更改,包括 9 次插入0 次删除
  1. 8 0
      core/os/input_event.cpp
  2. 1 0
      core/os/input_event.h

+ 8 - 0
core/os/input_event.cpp

@@ -937,6 +937,14 @@ bool InputEventAction::is_pressed() const {
 	return pressed;
 }
 
+bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
+	Ref<InputEventKey> event = p_event;
+	if (event.is_null())
+		return false;
+
+	return event->is_action(action);
+}
+
 bool InputEventAction::is_action(const StringName &p_action) const {
 
 	return action == p_action;

+ 1 - 0
core/os/input_event.h

@@ -467,6 +467,7 @@ public:
 
 	virtual bool is_action(const StringName &p_action) const;
 
+	virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
 	virtual bool is_action_type() const { return true; }
 	virtual String as_text() const;