Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Container

继承: Control < CanvasItem < Node < Object

派生: AspectRatioContainer, BoxContainer, CenterContainer, EditorProperty, FlowContainer, GraphElement, GridContainer, MarginContainer, PanelContainer, ScrollContainer, SplitContainer, SubViewportContainer, TabContainer

所有 GUI 容器的基类。

描述

所有 GUI 容器的基础节点。Container 包含其他控件,并自动以某种方式排列它们。可以继承此类来生成自定义的容器类。

教程

属性

MouseFilter

mouse_filter

1 (overrides Control)

方法

PackedInt32Array

_get_allowed_size_flags_horizontal ( ) virtual const

PackedInt32Array

_get_allowed_size_flags_vertical ( ) virtual const

void

fit_child_in_rect ( Control child, Rect2 rect )

void

queue_sort ( )


信号

pre_sort_children ( )

子节点将要被排序时发出。


sort_children ( )

需要对子节点进行排序时发出。


常量

NOTIFICATION_PRE_SORT_CHILDREN = 50

在子节点将要被排序之前通知,以防有事情需要事先处理。

NOTIFICATION_SORT_CHILDREN = 51

对子节点进行排序时的通知,必须立即服从。


方法说明

PackedInt32Array _get_allowed_size_flags_horizontal ( ) virtual const

实现以返回子节点允许的水平 SizeFlags 列表。这在技术上并不妨碍任何其他大小标志的使用,如果你的实现需要这样做。这只会限制检查器停靠面板中用户可用的选项。

注意:没有大小标志等同于有 Control.SIZE_SHRINK_BEGIN。因此,该值始终是隐式允许的。


PackedInt32Array _get_allowed_size_flags_vertical ( ) virtual const

实现以返回子节点允许的垂直 SizeFlags 列表。这在技术上并不妨碍任何其他大小标志的使用,如果你的实现需要这样做。这只会限制检查器停靠面板中用户可用的选项。

注意:没有大小标志等同于有 Control.SIZE_SHRINK_BEGIN。因此,该值始终是隐式允许的。


void fit_child_in_rect ( Control child, Rect2 rect )

在给定的矩形中适配子控件。这主要是用于创建自定义容器类的辅助工具。


void queue_sort ( )

将子节点的重排加入队列。虽然会被自动调用,但也可以在需要时手动调用。