ItemList support center_on_current().

This commit is contained in:
jinyangcruise
2025-11-15 11:30:39 +08:00
parent d5edd4a592
commit c82b5fe2ec
3 changed files with 43 additions and 2 deletions

View File

@@ -32,6 +32,15 @@
If [param selectable] is [code]true[/code], the list item will be selectable.
</description>
</method>
<method name="center_on_current">
<return type="void" />
<param index="0" name="center_verically" type="bool" default="true" />
<param index="1" name="center_horizontally" type="bool" default="true" />
<description>
Ensures the currently selected item (the first selected item if multiple selection is enabled) is visible, adjusting the scroll position as necessary to place the item at the center of the list if possible. See also [method ensure_current_is_visible].
Fails and prints an error if both arguments are [code]false[/code].
</description>
</method>
<method name="clear">
<return type="void" />
<description>
@@ -54,7 +63,7 @@
<method name="ensure_current_is_visible">
<return type="void" />
<description>
Ensure current selection is visible, adjusting the scroll position as necessary.
Ensures the currently selected item (the first selected item if multiple selection is enabled) is visible, adjusting the scroll position as necessary. See also [method center_on_current].
</description>
</method>
<method name="force_update_list_size">
@@ -240,7 +249,7 @@
<param index="0" name="idx" type="int" />
<param index="1" name="single" type="bool" default="true" />
<description>
Select the item at the specified index.
Selects the item at the specified index.
[b]Note:[/b] This method does not trigger the item selection signal.
</description>
</method>