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 🔗
The checkable item type of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
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.
bool popup/item_{index}/disabled = false 🔗
If true, the item at index is disabled.
Note: index is a value in the 0 .. item_count - 1 range.
Texture2D popup/item_{index}/icon 🔗
The icon of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
int popup/item_{index}/id = 0 🔗
The ID of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
bool popup/item_{index}/separator = false 🔗
If true, the item at index is a separator.
Note: index is a value in the 0 .. item_count - 1 range.
String popup/item_{index}/text = "" 🔗
The text of the item at index.
Note: index is a value in the 0 .. item_count - 1 range.
bool switch_on_hover = false 🔗
If true, when the cursor hovers above another MenuButton within the same parent which also has switch_on_hover enabled, it will close the current MenuButton and open the other one.
方法說明
返回這個按鈕中包含的 PopupMenu。
警告:這是一個必需的內部節點,移除和釋放它可能會導致當機。如果你想隱藏它或它的任何子節點,請使用其 Window.visible 屬性。
void set_disable_shortcuts(disabled: bool) 🔗
如果為 true,快捷方式將被禁用,無法用於觸發按鈕。
void show_popup() 🔗
調整該 MenuButton 的彈出位置和大小,然後顯示該 PopupMenu。請優先使用此方法,而不是使用 get_popup().popup()。