ItemList

Inherits: Control < CanvasItem < Node < Object

类别: 核心

简要说明

控件,该控件在单个列或多列中提供可选项(和/或图标)的列表。

方法

无效

add_icon_item ( Texture icon, bool selectable=true )

无效

add_item ( String text, Texture icon=null, bool selectable=true )

无效

clear ( )

无效

ensure_current_is_visible ( )

int

get_item_at_position ( Vector2 position, bool exact=false ) const

int

get_item_count ( ) const

Color

get_item_custom_bg_color ( int idx ) const

Color

get_item_custom_fg_color ( int idx ) const

Texture

get_item_icon ( int idx ) const

Color

get_item_icon_modulate ( int idx ) const

Rect2

get_item_icon_region ( int idx ) const

Variant

get_item_metadata ( int idx ) const

String

get_item_text ( int idx ) const

String

get_item_tooltip ( int idx ) const

PoolIntArray

get_selected_items ( )

VScrollBar

get_v_scroll ( )

bool

is_anything_selected ( )

bool

is_item_disabled ( int idx ) const

bool

is_item_icon_transposed ( int idx ) const

bool

is_item_selectable ( int idx ) const

bool

is_item_tooltip_enabled ( int idx ) const

bool

is_selected ( int idx ) const

无效

move_item ( int from_idx, int to_idx )

无效

remove_item ( int idx )

无效

select ( int idx, bool single=true )

无效

set_item_custom_bg_color ( int idx, Color custom_bg_color )

无效

set_item_custom_fg_color ( int idx, Color custom_fg_color )

无效

set_item_disabled ( int idx, bool disabled )

无效

set_item_icon ( int idx, Texture icon )

无效

set_item_icon_modulate ( int idx, Color modulate )

无效

set_item_icon_region ( int idx, Rect2 rect )

无效

set_item_icon_transposed ( int idx, bool rect )

无效

set_item_metadata ( int idx, Variant metadata )

无效

set_item_selectable ( int idx, bool selectable )

无效

set_item_text ( int idx, String text )

无效

set_item_tooltip ( int idx, String tooltip )

无效

set_item_tooltip_enabled ( int idx, bool enable )

无效

sort_items_by_text ( )

无效

unselect ( int idx )

无效

unselect_all ( )

主题属性

StyleBox

BG

StyleBox

bg_focus

StyleBox

光标

StyleBox

cursor_unfocused

Font

字体

Color

font_color

颜色(0.63、0.63、0.63、1)

Color

font_color_selected

颜色(1,1,1,1)

Color

guide_color

颜色(0,0,0,0.1)

int

H分离

4

int

icon_margin

4

int

line_separation

2

StyleBox

挑选出来的

StyleBox

selected_focus

int

V分离

2

信号

  • item_activated ( int index )

通过双击或按Enter键激活指定列表项时触发。

  • item_rmb_selected ( int index, Vector2 at_position )

当通过鼠标右键单击选择了指定的列表项时触发。

还提供了单击位置,允许在正确位置弹出相应的上下文菜单。

allow_rmb_select 必须启用。

  • item_selected ( int index )

选定指定项后触发。

allow_reselect 必须启用才能重新选择项目。

  • multi_selected ( int index, bool selected )

在允许多重选择的列表上更改多重选择时触发。

  • nothing_selected ( )

当鼠标左键单击在列表的矩形内但在空白处发出时触发。

  • rmb_clicked ( Vector2 at_position )

当右键单击在列表的矩形内但在空白处发出时触发。

allow_rmb_select 必须启用。

枚举

枚举 IconMode

  • ICON_MODE_TOP = 0

  • ICON_MODE_LEFT = 1

枚举 SelectMode

  • SELECT_SINGLE = 0 ---仅允许选择单个项目。

  • SELECT_MULTI = 1 ---允许通过按住ctrl或shift来选择多个项目。

描述

此控件提供可选择的项目列表,这些项目可能位于一个(或多个)列中,具有文本、图标或文本和图标选项。支持工具提示,并且列表中的每个项目的工具提示可能不同。

可以选择或取消选择列表中的可选项目,并且可以启用多项选择。也可以启用鼠标右键选择以允许使用弹出式上下文菜单。还可以通过双击或按Enter键“激活”项目。

属性描述

  • bool allow_reselect

违约

设定器

设置允许重新选择(值)

吸气剂

获取“允许重新选择”()

如果 true ,可以再次选择当前选定的项。

  • bool allow_rmb_select

违约

设定器

设置允许人民币选择(值)

吸气剂

获取允许人民币选择()

如果 true ,鼠标右键单击可以选择项目。

违约

设定器

设置自动高度(值)

吸气剂

具有自动高度()。

如果 true 控件将自动调整高度以适应其内容。

  • int fixed_column_width

违约

0

设定器

设置固定列宽度(值)

吸气剂

获取固定列宽度()。

以像素为单位设置默认列宽。如果保留默认值,则每个项目的宽度将等于其内容的宽度,列的宽度将不均匀。

违约

矢量2(0,0)

设定器

设置固定图标大小(值)

吸气剂

获取固定图标大小()。

以像素为单位设置默认图标大小。

违约

1

设定器

设置图标模式(值)

吸气剂

获取图标模式()

将图标的默认位置设置为 ICON_MODE_LEFTICON_MODE_TOP .

违约

1.0

设定器

设置图标比例(值)

吸气剂

获取图标比例

将图标大小设置为初始大小乘以指定比例。

  • int max_columns

违约

1

设定器

设置“最大”列(值)

吸气剂

获取“最大列数”()

设置列表的最大列数。如果设置为默认值以外的任何值,则内容将在指定的列之间拆分。

  • int max_text_lines

违约

1

设定器

设置“最大文本”行(值)

吸气剂

获取“最大文本行数”()

  • bool same_column_width

违约

设定器

设置相同的列宽度(值)

吸气剂

同一栏宽()吗?

如果设置为 true ,所有列将具有由指定的相同宽度 fixed_column_width .

违约

0

设定器

设置“选择”模式(值)

吸气剂

获取选择模式()

允许选择单个或多个项目。查看 SelectMode 常量。

方法说明

  • void add_icon_item ( Texture icon, bool selectable=true )

将项目添加到项目列表中,不带文本,只带图标。

向项目列表中添加具有指定文本的项目。指定 icon 或使用 null 作为 icon 对于没有图标的列表项。

如果可选的是 true ,列表项将是可选的。

  • void clear ( )

从列表中删除所有项目。

  • void ensure_current_is_visible ( )

确保当前选择可见,必要时调整滚动位置。

  • int get_item_at_position ( Vector2 position, bool exact=false ) const

给定控件内的位置,返回该点的项(如果有)。

  • int get_item_count ( ) const

返回列表中当前的项目数。

  • Color get_item_custom_bg_color ( int idx ) const

返回由指定的项的自定义背景色 idx 索引。

  • Color get_item_custom_fg_color ( int idx ) const

返回由指定的项的自定义前景色 idx 索引。

返回与指定索引关联的图标。

  • Color get_item_icon_modulate ( int idx ) const

返回A Color 在指定索引处调制项的图标。

  • Rect2 get_item_icon_region ( int idx ) const

返回指定索引的元数据值。

返回与指定索引关联的文本。

返回与指定索引关联的工具提示。

返回包含选定项索引的数组。

返回 Object 与列表关联的ID。

  • bool is_anything_selected ( )

返回 true 如果选择了一个或多个项目。

  • bool is_item_disabled ( int idx ) const

返回 true 如果指定索引处的项被禁用。

  • bool is_item_icon_transposed ( int idx ) const

  • bool is_item_selectable ( int idx ) const

返回 true 如果指定索引处的项是可选的。

  • bool is_item_tooltip_enabled ( int idx ) const

返回 true 如果为指定的项索引启用了工具提示。

  • bool is_selected ( int idx ) const

返回 true 如果当前选择了指定索引处的项。

  • void move_item ( int from_idx, int to_idx )

从索引中移动项 from_idxto_idx .

  • void remove_item ( int idx )

删除由指定的项 idx 列表中的索引。

  • void select ( int idx, bool single=true )

在指定索引处选择项。

注: 此方法不会触发项目选择信号。

  • void set_item_custom_bg_color ( int idx, Color custom_bg_color )

设置由指定的项的背景色 idx 指定的索引 Color .

var some_string = "Some text"
some_string.set_item_custom_bg_color(0,Color(1, 0, 0, 1) # This will set the background color of the first item of the control to red.
  • void set_item_custom_fg_color ( int idx, Color custom_fg_color )

设置由指定的项的前景色 idx 指定的索引 Color .

var some_string = "Some text"
some_string.set_item_custom_fg_color(0,Color(1, 0, 0, 1) # This will set the foreground color of the first item of the control to red.
  • void set_item_disabled ( int idx, bool disabled )

禁用(或启用)指定索引处的项。

无法选择禁用的项目,并且不会触发激活信号(双击或按Enter键时)。

设置(或替换)图标的 Texture 与指定索引关联。

  • void set_item_icon_modulate ( int idx, Color modulate )

设置调制 Color 与指定索引关联的项。

  • void set_item_icon_region ( int idx, Rect2 rect )

  • void set_item_icon_transposed ( int idx, bool rect )

  • void set_item_metadata ( int idx, Variant metadata )

设置要与与指定索引关联的项一起存储的值(任何类型)。

  • void set_item_selectable ( int idx, bool selectable )

允许或不允许选择与指定索引关联的项。

  • void set_item_text ( int idx, String text )

设置与指定索引关联的项的文本。

  • void set_item_tooltip ( int idx, String tooltip )

为与指定索引关联的项设置工具提示。

  • void set_item_tooltip_enabled ( int idx, bool enable )

设置是否为指定的项索引启用工具提示提示。

  • void sort_items_by_text ( )

按文本对列表中的项目排序。

  • void unselect ( int idx )

确保未选择与指定索引关联的项。

  • void unselect_all ( )

确保没有选择任何项。