Merge pull request #57811 from timothyqiu/tree-button-id-3.x

This commit is contained in:
Rémi Verschelde 2022-02-09 11:11:26 +01:00 committed by GitHub
commit 4ed2c8ee08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 3 deletions

View File

@ -51,6 +51,13 @@
[b]Note:[/b] Despite the name of this method, the focus cursor itself is only visible in [constant SELECT_MULTI] mode. [b]Note:[/b] Despite the name of this method, the focus cursor itself is only visible in [constant SELECT_MULTI] mode.
</description> </description>
</method> </method>
<method name="get_button_id_at_position" qualifiers="const">
<return type="int" />
<argument index="0" name="position" type="Vector2" />
<description>
Returns the button id at [code]position[/code], or -1 if no button is there.
</description>
</method>
<method name="get_column_at_position" qualifiers="const"> <method name="get_column_at_position" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="position" type="Vector2" /> <argument index="0" name="position" type="Vector2" />

View File

@ -14,11 +14,11 @@
<return type="void" /> <return type="void" />
<argument index="0" name="column" type="int" /> <argument index="0" name="column" type="int" />
<argument index="1" name="button" type="Texture" /> <argument index="1" name="button" type="Texture" />
<argument index="2" name="button_idx" type="int" default="-1" /> <argument index="2" name="id" type="int" default="-1" />
<argument index="3" name="disabled" type="bool" default="false" /> <argument index="3" name="disabled" type="bool" default="false" />
<argument index="4" name="tooltip" type="String" default="&quot;&quot;" /> <argument index="4" name="tooltip" type="String" default="&quot;&quot;" />
<description> <description>
Adds a button with [Texture] [code]button[/code] at column [code]column[/code]. The [code]button_idx[/code] index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code]. Adds a button with [Texture] [code]button[/code] at column [code]column[/code]. The [code]id[/code] is used to identify the button. If not specified, the next available index is used, which may be retrieved by calling [method get_button_count] immediately after this method. Optionally, the button can be [code]disabled[/code] and have a [code]tooltip[/code].
</description> </description>
</method> </method>
<method name="call_recursive" qualifiers="vararg"> <method name="call_recursive" qualifiers="vararg">
@ -65,6 +65,14 @@
Returns the [Texture] of the button at index [code]button_idx[/code] in column [code]column[/code]. Returns the [Texture] of the button at index [code]button_idx[/code] in column [code]column[/code].
</description> </description>
</method> </method>
<method name="get_button_by_id" qualifiers="const">
<return type="int" />
<argument index="0" name="column" type="int" />
<argument index="1" name="id" type="int" />
<description>
Returns the button index if there is a button with id [code]id[/code] in column [code]column[/code], otherwise returns -1.
</description>
</method>
<method name="get_button_count" qualifiers="const"> <method name="get_button_count" qualifiers="const">
<return type="int" /> <return type="int" />
<argument index="0" name="column" type="int" /> <argument index="0" name="column" type="int" />
@ -72,6 +80,14 @@
Returns the number of buttons in column [code]column[/code]. May be used to get the most recently added button's index, if no index was specified. Returns the number of buttons in column [code]column[/code]. May be used to get the most recently added button's index, if no index was specified.
</description> </description>
</method> </method>
<method name="get_button_id" qualifiers="const">
<return type="int" />
<argument index="0" name="column" type="int" />
<argument index="1" name="button_idx" type="int" />
<description>
Returns the id for the button at index [code]button_idx[/code] in column [code]column[/code].
</description>
</method>
<method name="get_button_tooltip" qualifiers="const"> <method name="get_button_tooltip" qualifiers="const">
<return type="String" /> <return type="String" />
<argument index="0" name="column" type="int" /> <argument index="0" name="column" type="int" />

View File

@ -776,9 +776,11 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_custom_as_button", "column", "enable"), &TreeItem::set_custom_as_button); ClassDB::bind_method(D_METHOD("set_custom_as_button", "column", "enable"), &TreeItem::set_custom_as_button);
ClassDB::bind_method(D_METHOD("is_custom_set_as_button", "column"), &TreeItem::is_custom_set_as_button); ClassDB::bind_method(D_METHOD("is_custom_set_as_button", "column"), &TreeItem::is_custom_set_as_button);
ClassDB::bind_method(D_METHOD("add_button", "column", "button", "button_idx", "disabled", "tooltip"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL("")); ClassDB::bind_method(D_METHOD("add_button", "column", "button", "id", "disabled", "tooltip"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL(""));
ClassDB::bind_method(D_METHOD("get_button_count", "column"), &TreeItem::get_button_count); ClassDB::bind_method(D_METHOD("get_button_count", "column"), &TreeItem::get_button_count);
ClassDB::bind_method(D_METHOD("get_button_tooltip", "column", "button_idx"), &TreeItem::get_button_tooltip); ClassDB::bind_method(D_METHOD("get_button_tooltip", "column", "button_idx"), &TreeItem::get_button_tooltip);
ClassDB::bind_method(D_METHOD("get_button_id", "column", "button_idx"), &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_idx"), &TreeItem::get_button); ClassDB::bind_method(D_METHOD("get_button", "column", "button_idx"), &TreeItem::get_button);
ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button); ClassDB::bind_method(D_METHOD("set_button", "column", "button_idx", "button"), &TreeItem::set_button);
ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button); ClassDB::bind_method(D_METHOD("erase_button", "column", "button_idx"), &TreeItem::erase_button);
@ -3844,6 +3846,7 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_at_position", "position"), &Tree::get_item_at_position); ClassDB::bind_method(D_METHOD("get_item_at_position", "position"), &Tree::get_item_at_position);
ClassDB::bind_method(D_METHOD("get_column_at_position", "position"), &Tree::get_column_at_position); ClassDB::bind_method(D_METHOD("get_column_at_position", "position"), &Tree::get_column_at_position);
ClassDB::bind_method(D_METHOD("get_drop_section_at_position", "position"), &Tree::get_drop_section_at_position); ClassDB::bind_method(D_METHOD("get_drop_section_at_position", "position"), &Tree::get_drop_section_at_position);
ClassDB::bind_method(D_METHOD("get_button_id_at_position", "position"), &Tree::get_button_id_at_position);
ClassDB::bind_method(D_METHOD("ensure_cursor_is_visible"), &Tree::ensure_cursor_is_visible); ClassDB::bind_method(D_METHOD("ensure_cursor_is_visible"), &Tree::ensure_cursor_is_visible);