Garry's Mod Wiki

DSlider

Description

Creates a slider that can be moved along the X and/or Y axis

View source

Parent

Derives methods, etc not listed on this page from Panel.

Events

DSlider:OnValueChanged( number x, number y )
Called when the values of this slider panel were changed.
For override by child panels, such as DNumSlider. Allows changing the output values of the slider.

Methods

This is used internally - although you're able to use it you probably shouldn't. Used internally to set the X axis convar.
This is used internally - although you're able to use it you probably shouldn't. Used internally to set the Y axis convar.
Identical to DSlider:IsEditing
number DSlider:GetLockX()
Returns the draggable panel's lock on the X axis. See DSlider:SetLockX for more info.
number DSlider:GetLockY()
Returns the draggable panel's lock on the Y axis. See DSlider:SetLockY for more info.
We advise against using this. It may be changed or removed in a future update. Does not affect anything by default. Returns the current notch color, set by DSlider:SetNotchColor
number DSlider:GetNotches()
We advise against using this. It may be changed or removed in a future update. Appears to be non functioning, however is still used by panels such as DNumSlider.
any DSlider:GetNumSlider()
We advise against using this. It may be changed or removed in a future update. Does nothing.
number DSlider:GetSlideX()
Returns the target position of the draggable "knob" panel of the slider on the X axis. Set by DSlider:SetSlideX.
number DSlider:GetSlideY()
Returns the target position of the draggable "knob" panel of the slider on the Y axis. Set by DSlider:SetSlideY.
Returns the value set by DSlider:SetTrapInside.
boolean DSlider:IsEditing()
Returns true if this element is being edited by the player.
This is used internally - although you're able to use it you probably shouldn't. Used internally to fire DSlider:OnValueChanged
DSlider:SetBackground( string path )
Sets the background for the slider.
DSlider:SetConVarX( string convar )
Sets the ConVar to be set when the slider changes on the X axis.
DSlider:SetConVarY( string convar )
Sets the ConVar to be set when the slider changes on the Y axis.
DSlider:SetDragging( boolean dragging )
This is used internally - although you're able to use it you probably shouldn't. Sets whether or not the slider is being dragged.
DSlider:SetImage()
We advise against using this. It may be changed or removed in a future update. Does nothing.
DSlider:SetImageColor()
We advise against using this. It may be changed or removed in a future update. Does nothing.
DSlider:SetLockX( number lockX = nil )
Sets the lock on the X axis. For example the value 0. 5 will lock the draggable panel to half the width of the slider's panel.
DSlider:SetLockY( number lockY = nil )
Sets the lock on the Y axis. For example the value 0. 5 will lock the draggable panel to half the height of the slider's panel.
DSlider:SetNotchColor( Color clr )
We advise against using this. It may be changed or removed in a future update. Does not affect anything by default. Sets the current notch color, overriding the color set by the derma skin.
DSlider:SetNotches( number notches )
We advise against using this. It may be changed or removed in a future update. Appears to be non functioning, however is still used by panels such as DNumSlider.
DSlider:SetNumSlider( any slider )
We advise against using this. It may be changed or removed in a future update. Does nothing.
DSlider:SetSlideX( number x )
Used to position the draggable panel of the slider on the X axis.
DSlider:SetSlideY( number y )
Used to position the draggable panel of the slider on the Y axis.
DSlider:SetTrapInside( boolean trap )
Makes the slider itself, the "knob", trapped within the bounds of the slider panel. Example:

Example

Make a slider at 50, 50 that can move 100 pixels on the X axis.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 500, 300 ) frame:Center() frame:MakePopup() local Slider = vgui.Create( "DSlider", frame ) Slider:SetPos( 50, 50 ) Slider:SetSize( 100, 20 )