Skip to content

Commit

Permalink
Fix issue causing input lock when drag scrolling a Tree element on …
Browse files Browse the repository at this point in the history
…touchscreen devices

Prior to this fix, scrolling via mouse drag on touchscreen devices, and
drag&drop operation on a `TreeItem` element would conflict with each other
preventing the drag scroll from being released when the mouse button is
released.

The issue is addressed by disabling drag&drop when drag scrolling is ongoing.
  • Loading branch information
m4gr3d committed Jul 18, 2024
1 parent 6b5825a commit 70d450d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5440,6 +5440,24 @@ int Tree::get_drop_section_at_position(const Point2 &p_pos) const {
return -100;
}

bool Tree::can_drop_data(const Point2 &p_point, const Variant &p_data) const {
if (drag_touching) {
// Disable data drag & drop when touch dragging.
return false;
}

return Control::can_drop_data(p_point, p_data);
}

Variant Tree::get_drag_data(const Point2 &p_point) {
if (drag_touching) {
// Disable data drag & drop when touch dragging.
return Variant();
}

return Control::get_drag_data(p_point);
}

TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {
if (root) {
Point2 pos = p_pos;
Expand Down
2 changes: 2 additions & 0 deletions scene/gui/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ class Tree : public Control {

virtual String get_tooltip(const Point2 &p_pos) const override;

virtual bool can_drop_data(const Point2 &p_point, const Variant &p_data) const override;
virtual Variant get_drag_data(const Point2 &p_point) override;
TreeItem *get_item_at_position(const Point2 &p_pos) const;
int get_column_at_position(const Point2 &p_pos) const;
int get_drop_section_at_position(const Point2 &p_pos) const;
Expand Down

0 comments on commit 70d450d

Please sign in to comment.