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_max_size

0

int

grabber_offset

0

int

tick_max_size

0

int

tick_offset

0

Texture2D

grabber

Texture2D

grabber_disabled

Texture2D

grabber_highlight

Texture2D

tick

AudioStream

drag_ended_sound

AudioStream

drag_started_sound

AudioStream

focus_sound

AudioStream

value_change_rejected_sound

AudioStream

value_changed_sound

StyleBox

grabber_area

StyleBox

grabber_area_highlight

StyleBox

slider


訊號

drag_ended(value_changed: bool) 🔗

停止拖動抓取器時發出。如果 value_changed 為 true,則 Range.value 與開始拖動時的值不同。


drag_started() 🔗

開始拖動抓取器時發出,時機在對應的 Range.value_changed 訊號之前。


列舉

enum TickPosition: 🔗

TickPosition TICK_POSITION_BOTTOM_RIGHT = 0

將刻度放置在 HSlider 的底部、VSlider 的右側。

TickPosition TICK_POSITION_TOP_LEFT = 1

將刻度放置在 HSlider 的頂部、VSlider 的左側。

TickPosition TICK_POSITION_BOTH = 2

在滑桿的兩側放置刻度。

TickPosition TICK_POSITION_CENTER = 3

在滑桿的中間放置刻度。


屬性說明

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 🔗

設定刻度的位置。詳見 TickPosition。


主題屬性說明

int center_grabber = 0 🔗

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


int grabber_max_size = 0 🔗

The maximum allowed size of the Slider's grabber icon. The grabber texture is scaled down so its widest axis is grabber_max_size and the other axis is scaled keeping the original ratio.


int grabber_offset = 0 🔗

抓取器的垂直或水平偏移量。


int tick_max_size = 0 🔗

The maximum allowed size of the Slider's tick icons. The tick texture is scaled down so its widest axis is tick_max_size and the other axis is scaled keeping the original ratio.


int tick_offset = 0 🔗

刻度的垂直或水平偏移量。頂部和左側刻度的偏移量是反的。


Texture2D grabber 🔗

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


Texture2D grabber_disabled 🔗

抓取器停用時的材質。


Texture2D grabber_highlight 🔗

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


Texture2D tick 🔗

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


AudioStream drag_ended_sound 🔗

Played when mouse or touch drag ends. This is also used by SpinBox when dragging over its arrows, or ColorPicker when dragging over its color wheel/rectangle.


AudioStream drag_started_sound 🔗

Played when mouse or touch drag begins. This is also used by SpinBox when dragging over its arrows, or ColorPicker when dragging over its color wheel/rectangle.


AudioStream focus_sound 🔗

Played when this Slider receives keyboard or gamepad-induced focus. Mouse or touch-induced focus does not play a focus sound.


AudioStream value_change_rejected_sound 🔗

Played when the value is attempted to be changed through keyboard or gamepad input, but the value is already at the minimum (or maximum).


AudioStream value_changed_sound 🔗

Played when the value is changed through keyboard or gamepad input. If the value is already at the minimum (or maximum), value_change_rejected_sound is played instead.


StyleBox grabber_area 🔗

抓取器左側或底部區域的背景。


StyleBox grabber_area_highlight 🔗

抓取器被懸停或聚焦時,顯示的左側或底部區域的背景。


StyleBox slider 🔗

整個滑桿的背景。影響 grabber_area 的高度或寬度。