Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
ItemList¶
Inherits: Control < CanvasItem < Node < Object
可选项目的垂直列表,可以有一列或多列。
Description¶
该控件提供了可选项目的垂直列表,这些项目可能位于单列或多列中,每个项目都有文本和图标选项。支持工具提示,并且列表中的每个项目可能会有所不同。
可以选择或取消选择列表中的可选项目,并且可以启用多项选择。也可以启用用鼠标右键进行选择,以允许使用弹出上下文菜单。项目也可以通过双击它们,或按 Enter 来“激活”。
项目文本只支持单行字符串。字符串中的换行符(例如 \n
)不会产生换行。在 ICON_MODE_TOP 模式下会启用文本换行,但默认情况下会调整列的宽度以完全适合其内容。需要将 fixed_column_width 设置得大于零,才能换行文本。
所有 set_*
方法都允许负的项目索引,例如 -1
访问的是最后一个项目,-2
选择的是倒数第二个项目,以此类推。
增量搜索:与 PopupMenu 和 Tree 一样,ItemList 支持在控件获得焦点时在列表内进行搜索。按下与项目名称的第一个字母匹配的键,以选择以给定字母开头的第一个项目。在该点之后,有两种方法可以执行增量搜索: 1) 在超时持续时间之前再次按下相同的键,以选择下一个以相同字母开头的项目。 2) 在超时时间前,按匹配单词剩余部分的字母键,将直接选择问题项。如果自上次击键被注册后,超时持续时间已过,则这两个动作都将被重置为列表的开头。可以通过更改 ProjectSettings.gui/timers/incremental_search_max_interval_msec 来调整超时持续时间。
Properties¶
|
||
|
||
|
||
|
||
clip_contents |
|
|
|
||
|
||
focus_mode |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
add_icon_item ( Texture2D icon, bool selectable=true ) |
|
add_item ( String text, Texture2D icon=null, bool selectable=true ) |
|
void |
clear ( ) |
void |
|
void |
deselect_all ( ) |
void |
|
void |
|
get_item_at_position ( Vector2 position, bool exact=false ) const |
|
get_item_custom_bg_color ( int idx ) const |
|
get_item_custom_fg_color ( int idx ) const |
|
get_item_icon ( int idx ) const |
|
get_item_icon_modulate ( int idx ) const |
|
get_item_icon_region ( int idx ) const |
|
get_item_language ( int idx ) const |
|
get_item_metadata ( int idx ) const |
|
get_item_rect ( int idx, bool expand=true ) const |
|
get_item_text ( int idx ) const |
|
get_item_text_direction ( int idx ) const |
|
get_item_tooltip ( int idx ) |