PopupMenu

Inherits: Popup < Control < CanvasItem < Node < Object

类别: 核心

简要说明

弹出菜单显示选项列表。

方法

无效

add_check_item ( String label, int id=-1, int accel=0 )

无效

add_check_shortcut ( ShortCut shortcut, int id=-1, bool global=false )

无效

add_icon_check_item ( Texture texture, String label, int id=-1, int accel=0 )

无效

add_icon_check_shortcut ( Texture texture, ShortCut shortcut, int id=-1, bool global=false )

无效

add_icon_item ( Texture texture, String label, int id=-1, int accel=0 )

无效

add_icon_shortcut ( Texture texture, ShortCut shortcut, int id=-1, bool global=false )

无效

add_item ( String label, int id=-1, int accel=0 )

无效

add_radio_check_item ( String label, int id=-1, int accel=0 )

无效

add_radio_check_shortcut ( ShortCut shortcut, int id=-1, bool global=false )

无效

add_separator ( String label="" )

无效

add_shortcut ( ShortCut shortcut, int id=-1, bool global=false )

无效

add_submenu_item ( String label, String submenu, int id=-1 )

无效

clear ( )

int

get_item_accelerator ( int idx ) const

int

get_item_count ( ) const

Texture

get_item_icon ( int idx ) const

int

get_item_id ( int idx ) const

int

get_item_index ( int id ) const

Variant

get_item_metadata ( int idx ) const

ShortCut

get_item_shortcut ( int idx ) const

String

get_item_submenu ( int idx ) const

String

get_item_text ( int idx ) const

String

get_item_tooltip ( int idx ) const

bool

is_hide_on_window_lose_focus ( ) const

bool

is_item_checkable ( int idx ) const

bool

is_item_checked ( int idx ) const

bool

is_item_disabled ( int idx ) const

bool

is_item_radio_checkable ( int idx ) const

bool

is_item_separator ( int idx ) const

bool

is_item_shortcut_disabled ( int idx ) const

无效

remove_item ( int idx )

无效

set_hide_on_window_lose_focus ( bool enable )

无效

set_item_accelerator ( int idx, int accel )

无效

set_item_as_checkable ( int idx, bool enable )

无效

set_item_as_radio_checkable ( int idx, bool enable )

无效

set_item_as_separator ( int idx, bool enable )

无效

set_item_checked ( int idx, bool checked )

无效

set_item_disabled ( int idx, bool disabled )

无效

set_item_icon ( int idx, Texture icon )

无效

set_item_id ( int idx, int id )

无效

set_item_metadata ( int idx, Variant metadata )

无效

set_item_multistate ( int idx, int state )

无效

set_item_shortcut ( int idx, ShortCut shortcut, bool global=false )

无效

set_item_shortcut_disabled ( int idx, bool disabled )

无效

set_item_submenu ( int idx, String submenu )

无效

set_item_text ( int idx, String text )

无效

set_item_tooltip ( int idx, String tooltip )

无效

toggle_item_checked ( int idx )

无效

toggle_item_multistate ( int idx )

主题属性

Texture

选中的

Font

字体

Color

font_color

颜色(0.88、0.88、0.88、1)

Color

font_color_accel

颜色(0.7、0.7、0.7、0.8)

Color

font_color_disabled

颜色(0.4、0.4、0.4、0.8)

Color

font_color_hover

颜色(0.88、0.88、0.88、1)

StyleBox

悬停

int

H分离

4

StyleBox

labeled_separator_left

StyleBox

labeled_separator_right

StyleBox

面板

StyleBox

panel_disabled

Texture

radio_checked

Texture

radio_unchecked

StyleBox

分离器

Texture

子菜单

Texture

未选中

int

V分离

4

信号

  • id_focused ( int id )

当用户导航到某个 id 使用 ui_upui_down 行动。

  • id_pressed ( int id )

当某个项目 id 按下或激活加速器。

  • index_pressed ( int index )

当某个项目 index 按下或激活加速器。

描述

PopupMenu 是一个 Control 显示选项列表。它们在工具栏或上下文菜单中很流行。

属性描述

违约

设定器

设置允许搜索(值)

吸气剂

获取“允许搜索”()

如果 true ,允许导航 PopupMenu 带字母键。

  • bool hide_on_checkable_item_selection

违约

设定器

设置“隐藏”选项(值)

吸气剂

在可勾选的项目上隐藏

如果 true ,隐藏 PopupMenu 选中复选框或单选按钮时。

  • bool hide_on_item_selection

违约

设定器

设置“隐藏”选项(值)

吸气剂

在项目选择()上隐藏

如果 true ,隐藏 PopupMenu 选择项目时。

  • bool hide_on_state_item_selection

违约

设定器

在“状态”选项上设置“隐藏”(值)

吸气剂

在状态项选择()上隐藏

如果 true ,隐藏 PopupMenu 当选择状态项时。

  • float submenu_popup_delay

违约

0.3

设定器

设置子菜单弹出延迟(值)

吸气剂

获取子菜单弹出延迟()

将子菜单项在鼠标悬停时弹出的延迟时间(以秒为单位)。如果弹出菜单作为另一个子菜单添加(作为子菜单),它将继承父菜单项的延迟时间。

方法说明

  • void add_check_item ( String label, int id=-1, int accel=0 )

添加带有文本的新可检查项 label .

id 可以选择提供,以及加速器 (accel )如果没有 id 如果提供,则将从索引创建一个。如果没有 accel 则为默认值 0 将分配给它。见 get_item_accelerator 有关加速器的详细信息。

注: 可检查项只显示复选标记,但没有任何内置的检查行为,必须手动检查/取消检查。见 set_item_checked 有关如何控制它的详细信息。

  • void add_check_shortcut ( ShortCut shortcut, int id=-1, bool global=false )

添加新的可检查项并分配指定的 ShortCut 为了它。将复选框的标签设置为 ShortCut 的名称。

id 可以选择提供。如果没有 id 如果提供,则将从索引创建一个。

注: 可检查项只显示复选标记,但没有任何内置的检查行为,必须手动检查/取消检查。见 set_item_checked 有关如何控制它的详细信息。

添加带有文本的新可检查项 label 和图标 texture .

id 可以选择提供,以及加速器 (accel )如果没有 id 如果提供,则将从索引创建一个。如果没有 accel 则为默认值 0 将分配给它。见 get_item_accelerator 有关加速器的详细信息。

注: 可检查项只显示复选标记,但没有任何内置的检查行为,必须手动检查/取消检查。见 set_item_checked 有关如何控制它的详细信息。

添加新的可检查项并分配指定的 ShortCut 和图标 texture 为了它。将复选框的标签设置为 ShortCut 的名称。

id 可以选择提供。如果没有 id 如果提供,则将从索引创建一个。

注: 可检查项只显示复选标记,但没有任何内置的检查行为,必须手动检查/取消检查。见 set_item_checked 有关如何控制它的详细信息。

添加带有文本的新项目 label 和图标 texture .

id 可以选择提供,以及加速器 (accel )如果没有 id 如果提供,则将从索引创建一个。如果没有 accel 则为默认值 0 将分配给它。见 get_item_accelerator 有关加速器的详细信息。

添加新项并指定 ShortCut 和图标 texture 为了它。将复选框的标签设置为 ShortCut 的名称。

id 可以选择提供。如果没有 id 如果提供,则将从索引创建一个。

添加带有文本的新项目 label .

id 可以选择提供,以及加速器 (accel )如果没有 id 如果提供,则将从索引创建一个。如果没有 accel 则为默认值 0 将分配给它。见 get_item_accelerator 有关加速器的详细信息。

  • void add_radio_check_item ( String label, int id=-1, int accel=0 )

添加带有文本的新单选按钮 label .

id 可以选择提供,以及加速器 (accel )如果没有 id 如果提供,则将从索引创建一个。如果没有 accel 则为默认值 0 将分配给它。见 get_item_accelerator 有关加速器的详细信息。

注: 可检查项只显示复选标记,但没有任何内置的检查行为,必须手动检查/取消检查。见 set_item_checked 有关如何控制它的详细信息。

  • void add_radio_check_shortcut ( ShortCut shortcut, int id=-1, bool global=false )

添加新的单选按钮并分配 ShortCut 为了它。将复选框的标签设置为 ShortCut 的名称。

id 可以选择提供。如果没有 id 如果提供,则将从索引创建一个。

注: 可检查项只显示复选标记,但没有任何内置的检查行为,必须手动检查/取消检查。见 set_item_checked 有关如何控制它的详细信息。

  • void add_separator ( String label="" )

在项之间添加分隔符。分隔符也占用索引。

添加一个 ShortCut .

id 可以选择提供。如果没有 id 如果提供,则将从索引创建一个。

添加将用作父级子菜单的项 PopupMenu 单击时为节点。这个 submenu 参数是子项的名称 PopupMenu 单击项时将显示的节点。

id 可以选择提供。如果没有 id 如果提供,则将从索引创建一个。

  • void clear ( )

从中删除所有项 PopupMenu .

  • int get_item_accelerator ( int idx ) const

返回索引处项的加速器 idx . 加速器是激活项目的键的特殊组合,不管哪个控件是焦点。

  • int get_item_count ( ) const

返回 PopupMenu .

返回索引处项目的图标 idx .

  • int get_item_id ( int idx ) const

返回索引处的项ID idx . id 可以手动分配,而索引不能。

  • int get_item_index ( int id ) const

返回包含指定的 id . 索引由引擎自动分配给每个项目。索引不能手动设置。

返回指定项的元数据,该元数据可以是任何类型。你可以用 set_item_metadata 这提供了一种将上下文数据分配给项的简单方法。

返回 ShortCut 与指定的 idx 项目。

返回索引处项的子菜单名称 idx . 见 add_submenu_item 有关如何添加子菜单的详细信息。

返回索引处的项文本 idx .

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

  • bool is_hide_on_window_lose_focus ( ) const

返回当窗口失去焦点时是否隐藏弹出窗口。

  • bool is_item_checkable ( int idx ) const

返回 true 如果索引处的项 idx 在某种程度上是可选中的,例如,如果它有复选框或单选按钮。

注: 可选中项只显示选中标记或单选按钮,但没有任何内置的检查行为,必须手动选中/取消选中。

  • bool is_item_checked ( int idx ) const

返回 true 如果索引处的项 idx 检查。

  • bool is_item_disabled ( int idx ) const

返回 true 如果索引处的项 idx 已禁用。当它被禁用时,它不能被选择,或者它的操作被调用。

set_item_disabled 有关如何禁用项目的详细信息。

  • bool is_item_radio_checkable ( int idx ) const

返回 true 如果索引处的项 idx 具有单选按钮样式检查功能。

注: 这是纯粹的修饰性的;您必须添加逻辑来选中/取消选中收音机组中的项目。

  • bool is_item_separator ( int idx ) const

返回 true 如果项目是分隔符。如果是,它将显示为一行。见 add_separator 有关如何添加分隔符的详细信息。

  • bool is_item_shortcut_disabled ( int idx ) const

返回指定项的快捷方式 idx 是否禁用。

  • void remove_item ( int idx )

删除索引处的项 idx 从菜单上。

注: 删除项后的项索引将被移动一个。

  • void set_hide_on_window_lose_focus ( bool enable )

隐藏 PopupMenu 当窗口失去焦点时。

  • void set_item_accelerator ( int idx, int accel )

在索引处设置项的加速器 idx . 加速器是激活项目的键的特殊组合,不管哪个控件是焦点。

  • void set_item_as_checkable ( int idx, bool enable )

设置项是否位于索引处 idx 有一个复选框。如果 false ,将项的类型设置为纯文本。

注: 可检查项只显示复选标记,但没有任何内置的检查行为,必须手动检查/取消检查。

  • void set_item_as_radio_checkable ( int idx, bool enable )

在指定索引处设置项的类型 idx 到单选按钮。如果为false,则将项的类型设置为纯文本。

  • void set_item_as_separator ( int idx, bool enable )

在索引处标记项目 idx 作为分隔符,这意味着它将显示为一行。如果 false ,将项的类型设置为纯文本。

  • void set_item_checked ( int idx, bool checked )

在索引处设置项的检查状态状态状态 idx .

  • void set_item_disabled ( int idx, bool disabled )

设置项是否位于索引处 idx 是否禁用。当它被禁用时,不能选择它,也不能调用它的操作。

替换 Texture 指定的图标 idx .

  • void set_item_id ( int idx, int id )

设置 id 在索引处的项 idx .

  • void set_item_metadata ( int idx, Variant metadata )

设置项的元数据,该元数据可以是任何类型。你以后可以用 get_item_metadata 这提供了一种将上下文数据分配给项的简单方法。

  • void set_item_multistate ( int idx, int state )

设置一个 ShortCut 对于指定的项目 idx .

  • void set_item_shortcut_disabled ( int idx, bool disabled )

禁用 ShortCut 指定索引的 idx .

  • void set_item_submenu ( int idx, String submenu )

在索引处设置项的子菜单 idx . 子菜单是子菜单的名称 PopupMenu 单击项时将显示的节点。

  • void set_item_text ( int idx, String text )

在索引处设置项的文本 idx .

  • void set_item_tooltip ( int idx, String tooltip )

设置 String 指定索引处的项的工具提示 idx .

  • void toggle_item_checked ( int idx )

切换指定索引项的检查状态 idx .

  • void toggle_item_multistate ( int idx )