Prevent dragging from SceneTree buttons
(cherry picked from commit 45d0799b5b
)
This commit is contained in:
parent
50d69a5a3d
commit
38509f1a89
|
@ -928,6 +928,10 @@ Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from
|
|||
if (!can_rename)
|
||||
return Variant(); //not editable tree
|
||||
|
||||
if (tree->get_button_id_at_position(p_point) != -1) {
|
||||
return Variant(); //dragging from button
|
||||
}
|
||||
|
||||
Vector<Node *> selected;
|
||||
Vector<Ref<Texture> > icons;
|
||||
TreeItem *next = tree->get_next_selected(NULL);
|
||||
|
|
|
@ -3799,6 +3799,47 @@ TreeItem *Tree::get_item_at_position(const Point2 &p_pos) const {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int Tree::get_button_id_at_position(const Point2 &p_pos) const {
|
||||
if (root) {
|
||||
Point2 pos = p_pos;
|
||||
pos -= cache.bg->get_offset();
|
||||
pos.y -= _get_title_button_height();
|
||||
if (pos.y < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (h_scroll->is_visible_in_tree()) {
|
||||
pos.x += h_scroll->get_value();
|
||||
}
|
||||
if (v_scroll->is_visible_in_tree()) {
|
||||
pos.y += v_scroll->get_value();
|
||||
}
|
||||
|
||||
int col, h, section;
|
||||
TreeItem *it = _find_item_at_pos(root, pos, col, h, section);
|
||||
|
||||
if (it) {
|
||||
const TreeItem::Cell &c = it->cells[col];
|
||||
int col_width = get_column_width(col);
|
||||
|
||||
for (int i = 0; i < col; i++) {
|
||||
pos.x -= get_column_width(i);
|
||||
}
|
||||
|
||||
for (int j = c.buttons.size() - 1; j >= 0; j--) {
|
||||
Ref<Texture> b = c.buttons[j].texture;
|
||||
Size2 size = b->get_size() + cache.button_pressed->get_minimum_size();
|
||||
if (pos.x > col_width - size.width) {
|
||||
return c.buttons[j].id;
|
||||
}
|
||||
col_width -= size.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
String Tree::get_tooltip(const Point2 &p_pos) const {
|
||||
|
||||
if (root) {
|
||||
|
|
|
@ -535,6 +535,7 @@ public:
|
|||
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;
|
||||
int get_button_id_at_position(const Point2 &p_pos) const;
|
||||
|
||||
void clear();
|
||||
|
||||
|
|
Loading…
Reference in New Issue