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.

Slider

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

被繼承: HSlider, VSlider

滑桿的抽象基底類別。

說明

滑桿的抽象基底類別,通過將抓取器(滑桿)沿水平軸或垂直軸移動類調整取值。滑桿是基於 Range 的控制項。

屬性

bool

editable

true

FocusMode

focus_mode

2 (overrides Control)

bool

scrollable

true

float

step

1.0 (overrides Range)

int

tick_count

0

bool

ticks_on_borders

false

TickPosition

ticks_position

0

主題屬性

int

center_grabber

0

int

grabber_offset

0

int

tick_offset

0

Texture2D

grabber

Texture2D

grabber_disabled

Texture2D

grabber_highlight

Texture2D

tick

StyleBox

grabber_area

StyleBox

grabber_area_highlight

StyleBox

slider


訊號

drag_ended(value_changed: bool) 🔗

Emitted when the grabber stops being dragged. If value_changed is true, Range.value is different from the value when the dragging was started.


drag_started() 🔗

Emitted when the grabber starts being dragged. This is emitted before the corresponding Range.value_changed signal.


列舉

enum TickPosition: 🔗

TickPosition TICK_POSITION_BOTTOM_RIGHT = 0

Places the ticks at the bottom of the HSlider, or right of the VSlider.

TickPosition TICK_POSITION_TOP_LEFT = 1

Places the ticks at the top of the HSlider, or left of the VSlider.

TickPosition TICK_POSITION_BOTH = 2

Places the ticks at the both sides of the slider.

TickPosition TICK_POSITION_CENTER = 3

Places the ticks at the center of the slider.


屬性說明

bool editable = true 🔗

  • void set_editable(value: bool)

  • bool is_editable()

如果為 true,則滑動條可以互動。如果為 false,則只能通過程式碼更改該值。


bool scrollable = true 🔗

  • void set_scrollable(value: bool)

  • bool is_scrollable()

如果為 true,則可以使用滑鼠滾輪更改該值。


int tick_count = 0 🔗

  • void set_ticks(value: int)

  • int get_ticks()

滑動條上顯示的刻度線數量,包括邊界刻度線。刻度是均勻分佈的數值標記。


bool ticks_on_borders = false 🔗

  • void set_ticks_on_borders(value: bool)

  • bool get_ticks_on_borders()

如果為 true,則滑動條將顯示最小值和最大值的刻度。


TickPosition ticks_position = 0 🔗

Sets the position of the ticks. See TickPosition for details.


主題屬性說明

int center_grabber = 0 🔗

布林常數。如果為 1,則會忽略抓取器紋理的大小,根據其中心位置將其縮放到捲軸的邊界。


int grabber_offset = 0 🔗

Vertical or horizontal offset of the grabber.


int tick_offset = 0 🔗

Vertical or horizontal offset of the ticks. The offset is reversed for top or left ticks.


Texture2D grabber 🔗

用作拖動條的紋理(可拖動的元素)。


Texture2D grabber_disabled 🔗

抓取器禁用時的材質。


Texture2D grabber_highlight 🔗

抓取器獲得焦點時的材質。


Texture2D tick 🔗

刻度的紋理。當 tick_count 大於 0 時可見。


StyleBox grabber_area 🔗

The background of the area to the left or bottom of the grabber.


StyleBox grabber_area_highlight 🔗

The background of the area to the left or bottom of the grabber that displays when it's being hovered or focused.


StyleBox slider 🔗

The background for the whole slider. Affects the height or width of the grabber_area.