Garry's Mod Wiki

DNumSlider

Description

The DNumSlider allows you to create a slider, allowing the user to slide it to set a value, or changing the value in the box.

Parent

Derives from Panel.

Methods

number DNumSlider:GetDecimals()
Returns the amount of numbers after the decimal point.
number DNumSlider:GetDefaultValue()
Returns the default value of the slider, if one was set by DNumSlider:SetDefaultValue
number DNumSlider:GetMax()
Returns the maximum value of the slider
number DNumSlider:GetMin()
Returns the minimum value of the slider
number DNumSlider:GetRange()
Returns the range of the slider, basically maximum value - minimum value.
Panel DNumSlider:GetTextArea()
Returns the DTextEntry component of the slider.
number DNumSlider:GetValue()
Returns the value of the DNumSlider
boolean DNumSlider:IsEditing()
Returns true if either the DTextEntry, the DSlider or the DNumberScratch are being edited.
DNumSlider:OnValueChanged( number value )
Called when the value of the slider is changed, through code or changing the slider.
DNumSlider:ResetToDefaultValue()
Resets the slider to the default value, if one was set by DNumSlider:SetDefaultValue. This function is called by the DNumSlider when user middle mouse clicks on the draggable knob of the slider.
DNumSlider:SetConVar( string cvar )
Sets the console variable to be updated when the value of the slider is changed.
DNumSlider:SetDark( boolean dark )
Calls DLabel:SetDark on the DLabel part of the DNumSlider.
DNumSlider:SetDecimals( number decimals )
Sets the desired amount of numbers after the decimal point. This doesn't affect values passed to DNumSlider:OnValueChanged.To get right values passed to DNumSlider:OnValueChanged use math.Round.
DNumSlider:SetDefaultValue( number default )
Sets the default value of the slider, to be used by DNumSlider:ResetToDefaultValue or by middle mouse clicking the draggable knob of the slider.
DNumSlider:SetMax( number max )
Sets the maximum value for the slider.
DNumSlider:SetMin( number min )
Sets the minimum value for the slider
DNumSlider:SetMinMax( number min, number max )
Sets the minimum and the maximum value of the slider.
DNumSlider:SetValue( number val )
Sets the value of the DNumSlider.
number, number DNumSlider:TranslateSliderValues( number x, number y )
This is used internally - although you're able to use it you probably shouldn't.
DNumSlider:UpdateNotches()
This is used internally - although you're able to use it you probably shouldn't.
DNumSlider:ValueChanged( number value )
This is used internally - although you're able to use it you probably shouldn't. Called when the value has been changed. This will also be called when the user manually changes the value through the text panel. This is an internal function. Override DNumSlider:OnValueChanged instead.

Example

Attempts to create a DNumSlider.

local DermaPanel = vgui.Create( "DFrame" ) -- Create a panel to parent it to DermaPanel:SetSize( 500, 200 ) -- Set the size DermaPanel:Center() -- Center it DermaPanel:MakePopup() -- Make it a popup local DermaNumSlider = vgui.Create( "DNumSlider", DermaPanel ) DermaNumSlider:SetPos( 50, 50 ) -- Set the position DermaNumSlider:SetSize( 300, 100 ) -- Set the size DermaNumSlider:SetText( "Maximum props" ) -- Set the text above the slider DermaNumSlider:SetMin( 0 ) -- Set the minimum number you can slide to DermaNumSlider:SetMax( 256 ) -- Set the maximum number you can slide to DermaNumSlider:SetDecimals( 0 ) -- Decimal places - zero for whole number DermaNumSlider:SetConVar( "sbox_maxprops" ) -- Changes the ConVar when you slide -- If not using convars, you can use this hook + Panel.SetValue() DermaNumSlider.OnValueChanged = function( self, value ) -- Called when the slider value changes end
Output:

Page Links


Special Pages


Wikis

?

Render Time: 32ms

DB GetPage 3
Generate Html 6
SaveChanges (1) 9
Render Body 0
Render Sidebar 11