summaryrefslogtreecommitdiffstats
path: root/core/os/input_event.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-03-03 19:52:18 -0300
committerJuan Linietsky <juan@godotengine.org>2019-03-03 19:53:13 -0300
commita1e73dcc944627ab7185aec7cd4141fe4ebb97d7 (patch)
tree917b9912d48607e19d214a0e3931dd325f75d1e6 /core/os/input_event.cpp
parenta9fe834a8e962a7b9e15e5dc218af4b857b47da4 (diff)
downloadredot-engine-a1e73dcc944627ab7185aec7cd4141fe4ebb97d7.tar.gz
Add support for event accumlation (off by default, on for editor), fixes #26536
Diffstat (limited to 'core/os/input_event.cpp')
-rw-r--r--core/os/input_event.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 24ec8a1963..40308f4f7d 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -122,6 +122,8 @@ void InputEvent::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type);
+ ClassDB::bind_method(D_METHOD("accumulate", "with_event"), &InputEvent::accumulate);
+
ClassDB::bind_method(D_METHOD("xformed_by", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2()));
ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device");
@@ -620,6 +622,44 @@ String InputEventMouseMotion::as_text() const {
return "InputEventMouseMotion : button_mask=" + button_mask_string + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
}
+bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
+
+ Ref<InputEventMouseMotion> motion = p_event;
+ if (motion.is_null())
+ return false;
+
+ if (is_pressed() != motion->is_pressed()) {
+ return false;
+ }
+
+ if (get_button_mask() != motion->get_button_mask()) {
+ return false;
+ }
+
+ if (get_shift() != motion->get_shift()) {
+ return false;
+ }
+
+ if (get_control() != motion->get_control()) {
+ return false;
+ }
+
+ if (get_alt() != motion->get_alt()) {
+ return false;
+ }
+
+ if (get_metakey() != motion->get_metakey()) {
+ return false;
+ }
+
+ set_position(motion->get_position());
+ set_global_position(motion->get_global_position());
+ set_speed(motion->get_speed());
+ relative += motion->get_relative();
+
+ return true;
+}
+
void InputEventMouseMotion::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative);