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...
MenuButton
繼承: Button < BaseButton < Control < CanvasItem < Node < Object
點選後會彈出 PopupMenu 的按鈕。
說明
點選後會彈出 PopupMenu 的按鈕。可以使用 get_popup().add_item("功能表專案名稱") 在這個 PopupMenu 中建立新的功能表專案,也可以直接從 Godot 編輯器的屬性檢視器中建立。
另見 BaseButton,提供了與該節點相關的常用屬性和方法。
屬性
action_mode |
|
|
flat |
|
|
focus_mode |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
toggle_mode |
|
方法
get_popup() const |
|
void |
set_disable_shortcuts(disabled: bool) |
void |
訊號
about_to_popup() 🔗
該 MenuButton 的 PopupMenu 即將顯示時發出。
屬性說明
目前列表中的專案數。
int popup/item_{index}/checkable = 0 🔗
索引為 index 的可勾選選單項的型別。
注意: index 的取值必須在 0 .. item_count - 1 範圍內。
bool popup/item_{index}/checked = false 🔗
If true, the item at index is checked.
Note: index is a value in the 0 .. item_count - 1 range.
Note: An item cannot be both in a checked and indeterminate state, so if checked is set to true, popup/item_{index}/indeterminate will be set to false.
bool popup/item_{index}/disabled = false 🔗
如果為 true,則停用位於 index 處的項目。
注意: index 的取值範圍為 0 .. item_count - 1。
Texture2D popup/item_{index}/icon 🔗
位於 index 處的項目的圖示。
注意: index 的取值範圍為 0 .. item_count - 1。
int popup/item_{index}/id = 0 🔗
索引為 index 的選單項的 ID。
注意: index 的取值必須在 0 .. item_count - 1 範圍內。
bool popup/item_{index}/indeterminate = false 🔗
If true, the item at index is in an indeterminate state.
Note: index is a value in the 0 .. item_count - 1 range.
Note: An item cannot be both in a checked and indeterminate state, so if indeterminate is set to true, popup/item_{index}/checked will be set to false.
bool popup/item_{index}/separator = false 🔗
如果為 true,則索引為 index 的選單項是一個分隔符。
注意: index 的取值必須在 0 .. item_count - 1 範圍內。
String popup/item_{index}/text = "" 🔗
位於 index 處的項目的文字。
注意: index 的取值範圍為 0 .. item_count - 1。
bool switch_on_hover = false 🔗
如果為 true,當游標懸停在同一父級中也啟用了 switch_on_hover 的另一個 MenuButton 上方時,它將關閉目前的 MenuButton 並打開另一個。
方法說明
返回這個按鈕中包含的 PopupMenu。
警告:這是一個必需的內部節點,移除和釋放它可能會導致當機。如果你想隱藏它或它的任何子節點,請使用其 Window.visible 屬性。
void set_disable_shortcuts(disabled: bool) 🔗
如果為 true,快捷方式將被停用,無法用於觸發按鈕。
void show_popup() 🔗
調整該 MenuButton 的彈出位置和大小,然後顯示該 PopupMenu。請優先使用此方法,而不是使用 get_popup().popup()。