Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set the tooltip text of a TreeItem button #78393

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/classes/TreeItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,15 @@
If [code]true[/code], disables the button at index [param button_index] in the given [param column].
</description>
</method>
<method name="set_button_tooltip_text">
<return type="void" />
<param index="0" name="column" type="int" />
<param index="1" name="button_index" type="int" />
<param index="2" name="tooltip" type="String" />
<description>
Sets the tooltip text for the button at index [param button_index] in the given [param column].
</description>
</method>
<method name="set_cell_mode">
<return type="void" />
<param index="0" name="column" type="int" />
Expand Down
7 changes: 7 additions & 0 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,12 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const {
return -1;
}

void TreeItem::set_button_tooltip_text(int p_column, int p_index, const String &p_tooltip) {
ERR_FAIL_INDEX(p_column, cells.size());
ERR_FAIL_INDEX(p_index, cells[p_column].buttons.size());
cells.write[p_column].buttons.write[p_index].tooltip = p_tooltip;
}

void TreeItem::set_button(int p_column, int p_index, const Ref<Texture2D> &p_button) {
ERR_FAIL_COND(p_button.is_null());
ERR_FAIL_INDEX(p_column, cells.size());
Expand Down Expand Up @@ -1586,6 +1592,7 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_index"), &TreeItem::get_button_id);
ClassDB::bind_method(D_METHOD("get_button_by_id", "column", "id"), &TreeItem::get_button_by_id);
ClassDB::bind_method(D_METHOD("get_button", "column", "button_index"), &TreeItem::get_button);
ClassDB::bind_method(D_METHOD("set_button_tooltip_text", "column", "button_index", "tooltip"), &TreeItem::set_button_tooltip_text);
ClassDB::bind_method(D_METHOD("set_button", "column", "button_index", "button"), &TreeItem::set_button);
ClassDB::bind_method(D_METHOD("erase_button", "column", "button_index"), &TreeItem::erase_button);
ClassDB::bind_method(D_METHOD("set_button_disabled", "column", "button_index", "disabled"), &TreeItem::set_button_disabled);
Expand Down
1 change: 1 addition & 0 deletions scene/gui/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class TreeItem : public Object {
int get_button_id(int p_column, int p_index) const;
void erase_button(int p_column, int p_index);
int get_button_by_id(int p_column, int p_id) const;
void set_button_tooltip_text(int p_column, int p_index, const String &p_tooltip);
void set_button(int p_column, int p_index, const Ref<Texture2D> &p_button);
void set_button_color(int p_column, int p_index, const Color &p_color);
void set_button_disabled(int p_column, int p_index, bool p_disabled);
Expand Down