Merge pull request #74085 from AThousandShips/tree_set_selected_3_x
[3.x] Backport Tree::set_selected
This commit is contained in:
commit
d627f4f80d
3 changed files with 20 additions and 0 deletions
|
@ -202,6 +202,14 @@
|
|||
Sets the title of a column.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_selected">
|
||||
<return type="void" />
|
||||
<argument index="0" name="item" type="Object" />
|
||||
<argument index="1" name="column" type="int" />
|
||||
<description>
|
||||
Selects the specified [TreeItem] and column.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="allow_reselect" type="bool" setter="set_allow_reselect" getter="get_allow_reselect" default="false">
|
||||
|
|
|
@ -3157,6 +3157,12 @@ TreeItem *Tree::get_selected() const {
|
|||
return selected_item;
|
||||
}
|
||||
|
||||
void Tree::set_selected(TreeItem *p_item, int p_column) {
|
||||
ERR_FAIL_INDEX(p_column, columns.size());
|
||||
ERR_FAIL_COND(!p_item);
|
||||
select_single_item(p_item, get_root(), p_column);
|
||||
}
|
||||
|
||||
int Tree::get_selected_column() const {
|
||||
return selected_col;
|
||||
}
|
||||
|
@ -3832,6 +3838,7 @@ void Tree::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("is_root_hidden"), &Tree::is_root_hidden);
|
||||
ClassDB::bind_method(D_METHOD("get_next_selected", "from"), &Tree::_get_next_selected);
|
||||
ClassDB::bind_method(D_METHOD("get_selected"), &Tree::get_selected);
|
||||
ClassDB::bind_method(D_METHOD("set_selected", "item", "column"), &Tree::_set_selected);
|
||||
ClassDB::bind_method(D_METHOD("get_selected_column"), &Tree::get_selected_column);
|
||||
ClassDB::bind_method(D_METHOD("get_pressed_button"), &Tree::get_pressed_button);
|
||||
ClassDB::bind_method(D_METHOD("set_select_mode", "mode"), &Tree::set_select_mode);
|
||||
|
|
|
@ -527,6 +527,10 @@ protected:
|
|||
scroll_to_item(Object::cast_to<TreeItem>(p_item));
|
||||
}
|
||||
|
||||
void _set_selected(Object *p_item, int p_column) {
|
||||
set_selected(Object::cast_to<TreeItem>(p_item), p_column);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual String get_tooltip(const Point2 &p_pos) const;
|
||||
|
||||
|
@ -549,6 +553,7 @@ public:
|
|||
bool is_root_hidden() const;
|
||||
TreeItem *get_next_selected(TreeItem *p_item);
|
||||
TreeItem *get_selected() const;
|
||||
void set_selected(TreeItem *p_item, int p_column = 0);
|
||||
int get_selected_column() const;
|
||||
int get_pressed_button() const;
|
||||
void set_select_mode(SelectMode p_mode);
|
||||
|
|
Loading…
Reference in a new issue