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.

FoldableContainer

繼承: Container < Control < CanvasItem < Node < Object

能夠展開、折疊的容器。

說明

能夠展開、折疊的容器,標題中可以新增按鈕等控制項。這也叫做手風琴。

標題可以放在容器的頂部或底部。點選標題或在聚焦時按下 ui_accept 可以將容器展開或折疊。容器折疊時子控制項節點隱藏。忽略非控制項子節點。

可折疊容器可以與其他可折疊容器分組,這樣一次只能打開其中一個;見 foldable_group 和 FoldableGroup。

屬性

FocusMode

focus_mode

2 (overrides Control)

FoldableGroup

foldable_group

bool

folded

false

String

language

""

MouseFilter

mouse_filter

0 (overrides Control)

String

title

""

HorizontalAlignment

title_alignment

0

TitlePosition

title_position

0

TextDirection

title_text_direction

0

OverrunBehavior

title_text_overrun_behavior

0

方法

void

add_title_bar_control(control: Control)

void

expand()

void

fold()

void

remove_title_bar_control(control: Control)

主題屬性

Color

collapsed_font_color

Color(1, 1, 1, 1)

Color

font_color

Color(0.875, 0.875, 0.875, 1)

Color

font_outline_color

Color(1, 1, 1, 1)

Color

hover_font_color

Color(0.95, 0.95, 0.95, 1)

int

h_separation

2

int

outline_size

0

Font

font

int

font_size

Texture2D

expanded_arrow

Texture2D

expanded_arrow_mirrored

Texture2D

folded_arrow

Texture2D

folded_arrow_mirrored

StyleBox

focus

StyleBox

panel

StyleBox

title_collapsed_hover_panel

StyleBox

title_collapsed_panel

StyleBox

title_hover_panel

StyleBox

title_panel


訊號

folding_changed(is_folded: bool) 🔗

容器折疊/展開時發出。


列舉

enum TitlePosition: 🔗

TitlePosition POSITION_TOP = 0

標題出現在容器頂部。

TitlePosition POSITION_BOTTOM = 1

標題出現在容器底部。同時會讓所有 StyleBox 垂直翻轉。


屬性說明

FoldableGroup foldable_group 🔗

與容器關聯的 FoldableGroup。多個 FoldableContainer 節點具有相同的分組時,只允許有一個處於展開狀態。


bool folded = false 🔗

  • void set_folded(value: bool)

  • bool is_folded()

如果設為 true,該容器將會被折疊,並隱藏其所有子節點。


String language = "" 🔗

語言程式碼,用於文字塑形算法。如果留空則使用目前區域設定。


String title = "" 🔗

容器的標題文字。


HorizontalAlignment title_alignment = 0 🔗

標題的水平文字對齊方式。


TitlePosition title_position = 0 🔗

標題的位置。


TextDirection title_text_direction = 0 🔗

標題的文字書寫方向。


OverrunBehavior title_text_overrun_behavior = 0 🔗

定義標題在文字比可用空間更長時的行為。


方法說明

void add_title_bar_control(control: Control) 🔗

新增放置在容器標題旁的 Control,遮擋可點選區域。主要用途是新增 Button 節點,但可以是任何 Control。

控制項會被新增為該容器的子節點,必要時會從之前的父節點中移除。這些控制項是右對齊的,最先新增的控制項位於最左側。


void expand() 🔗

展開容器,發出 folding_changed。


void fold() 🔗

折疊容器,發出 folding_changed。


void remove_title_bar_control(control: Control) 🔗

移除使用 add_title_bar_control() 新增的 Control。該節點不會自動釋放,你需要使用 Node.queue_free()。


主題屬性說明

Color collapsed_font_color = Color(1, 1, 1, 1) 🔗

折疊時的標題字型顏色。


Color font_color = Color(0.875, 0.875, 0.875, 1) 🔗

展開時的標題字型顏色。


Color font_outline_color = Color(1, 1, 1, 1) 🔗

標題字型輪廓顏色。


Color hover_font_color = Color(0.95, 0.95, 0.95, 1) 🔗

標題字型懸停顏色。


int h_separation = 2 🔗

標題的圖示和文字之間以及標題欄控制項之間的水平間距。


int outline_size = 0 🔗

標題字型輪廓大小。


Font font 🔗

標題字型。


int font_size 🔗

標題字型大小。


Texture2D expanded_arrow 🔗

展開時使用的標題圖示。


Texture2D expanded_arrow_mirrored 🔗

展開時使用的標題圖示(用於底部標題)。


Texture2D folded_arrow 🔗

折疊時使用的標題圖示(用於從左至右版面配置)。


Texture2D folded_arrow_mirrored 🔗

展開時使用的標題圖示(用於從右至左版面配置)。


StyleBox focus 🔗

FoldableContainer 擁有 GUI 焦點時使用的背景。focus StyleBox 顯示在基礎 StyleBox 之上,所以應該使用部分透明的 StyleBox,確保基礎 StyleBox 仍然可見。代表輪廓或底線的 StyleBox 可以很好地實現這個目的。要停用聚焦的視覺效果,請指定 StyleBoxEmpty 資源。請注意,停用聚焦的視覺效果會影響使用鍵盤/控制器進行導航的可用性,所以出於無障礙存取的原因,不建議這樣做。


StyleBox panel 🔗

FoldableContainer 的預設背景。


StyleBox title_collapsed_hover_panel 🔗

處於折疊狀態下,滑鼠游標進入標題區域時使用的背景。


StyleBox title_collapsed_panel 🔗

處於折疊狀態下,FoldableContainer 標題的預設背景。


StyleBox title_hover_panel 🔗

處於展開狀態下,滑鼠游標進入標題區域時使用的背景。


StyleBox title_panel 🔗

處於展開狀態下,FoldableContainer 標題的預設背景。