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...
ScrollContainer¶
Inherits: Container < Control < CanvasItem < Node < Object
Inherited By: EditorInspector
需要时能够为子控件提供滚动条的容器。
Description¶
用于在需要时为子控件提供滚动条的容器。滚动条会自动绘制在右侧(垂直滚动条)或底部(水平滚动条),拖动滚动条能够移动 ScrollContainer 中的可见 Control(及其子项)。滚动条会根据该 Control 的 Control.custom_minimum_size 相对于 ScrollContainer 的大小自动调整抓取器的大小。
Tutorials¶
Properties¶
clip_contents |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
void |
ensure_control_visible ( Control control ) |
get_h_scroll_bar ( ) |
|
get_v_scroll_bar ( ) |
Theme Properties¶
Signals¶
scroll_ended ( )
Emitted when scrolling stops when dragging the scrollable area with a touch event. This signal is not emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
Note: This signal is only emitted on Android or iOS, or on desktop/web platforms when ProjectSettings.input_devices/pointing/emulate_touch_from_mouse is enabled.
scroll_started ( )
Emitted when scrolling starts when dragging the scrollable area with a touch event. This signal is not emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
Note: This signal is only emitted on Android or iOS, or on desktop/web platforms when ProjectSettings.input_devices/pointing/emulate_touch_from_mouse is enabled.
Enumerations¶
enum ScrollMode:
ScrollMode SCROLL_MODE_DISABLED = 0
禁用滚动,滚动条不可见。
ScrollMode SCROLL_MODE_AUTO = 1
启用滚动,滚动条仅在需要时可见,即容器的内容比容器大时。
ScrollMode SCROLL_MODE_SHOW_ALWAYS = 2
启用滚动,滚动条始终可见。
ScrollMode SCROLL_MODE_SHOW_NEVER = 3
启用滚动,滚动条隐藏。
Property Descriptions¶
bool follow_focus = false
如果为 true
,则 ScrollContainer 将自动滚动到获得焦点的子项(包括间接子项)以确保它们完全可见。
ScrollMode horizontal_scroll_mode = 1
void set_horizontal_scroll_mode ( ScrollMode value )
ScrollMode get_horizontal_scroll_mode ( )
控制水平滚动条是否可用、应该何时可见。选项见 ScrollMode。
int scroll_deadzone = 0
触摸滚动的死区。较低的死区使滚动更加敏感。
int scroll_horizontal = 0
The current horizontal scroll value.
Note: If you are setting this value in the Node._ready function or earlier, it needs to be wrapped with Object.set_deferred, since scroll bar's Range.max_value is not initialized yet.
func _ready():
set_deferred("scroll_horizontal", 600)
float scroll_horizontal_custom_step = -1.0
覆盖点击内部滚动条的水平增减按钮或 ScrollBar 处于聚焦状态下使用方向键时使用的 ScrollBar.custom_step。
int scroll_vertical = 0
当前的垂直滚动值。
注意:与 scroll_horizontal 一样,最初设置时需要进行延迟。
func _ready():
set_deferred("scroll_vertical", 600)
float scroll_vertical_custom_step = -1.0
覆盖点击内部滚动条的垂直增减按钮或 ScrollBar 处于聚焦状态下使用方向