diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-01-24 23:16:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-24 23:16:31 +0100 |
commit | 30701e3966fe0869868d09d57249ff140e55849e (patch) | |
tree | ca90cd57d157c61b3cd503c04f376ab1e06092dd /scene/gui | |
parent | 672363f295495478ef7d03ea00878b8ebfbdb430 (diff) | |
parent | 342a31e3265508a3fc79b08053bf63be9ff2da51 (diff) |
Merge pull request #57155 from KoBeWi/drag_by_force
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/view_panner.cpp | 11 | ||||
-rw-r--r-- | scene/gui/view_panner.h | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/scene/gui/view_panner.cpp b/scene/gui/view_panner.cpp index 7476887877..71865b4864 100644 --- a/scene/gui/view_panner.cpp +++ b/scene/gui/view_panner.cpp @@ -81,7 +81,12 @@ bool ViewPanner::gui_input(const Ref<InputEvent> &p_event, Rect2 p_canvas_rect) return false; } - if (mb->get_button_index() == MouseButton::MIDDLE || (enable_rmb && mb->get_button_index() == MouseButton::RIGHT) || (!simple_panning_enabled && mb->get_button_index() == MouseButton::LEFT && is_panning())) { + bool is_drag_event = mb->get_button_index() == MouseButton::MIDDLE || + (enable_rmb && mb->get_button_index() == MouseButton::RIGHT) || + (!simple_panning_enabled && mb->get_button_index() == MouseButton::LEFT && is_panning()) || + (force_drag && mb->get_button_index() == MouseButton::LEFT); + + if (is_drag_event) { if (mb->is_pressed()) { is_dragging = true; } else { @@ -166,6 +171,10 @@ bool ViewPanner::is_panning() const { return is_dragging || pan_key_pressed; } +void ViewPanner::set_force_drag(bool p_force) { + force_drag = p_force; +} + ViewPanner::ViewPanner() { Array inputs; inputs.append(InputEventKey::create_reference(Key::SPACE)); diff --git a/scene/gui/view_panner.h b/scene/gui/view_panner.h index 8423c2a1c0..5b820c5f8f 100644 --- a/scene/gui/view_panner.h +++ b/scene/gui/view_panner.h @@ -48,6 +48,8 @@ public: private: bool is_dragging = false; bool pan_key_pressed = false; + bool force_drag = false; + bool enable_rmb = false; bool simple_panning_enabled = false; @@ -70,6 +72,7 @@ public: void setup(ControlScheme p_scheme, Ref<Shortcut> p_shortcut, bool p_simple_panning); bool is_panning() const; + void set_force_drag(bool p_force); bool gui_input(const Ref<InputEvent> &p_ev, Rect2 p_canvas_rect = Rect2()); void release_pan_key(); |