Garry's Mod Wiki

DNumberWang

Description

DNumberWang is a VGUI element that allows you to input a numeric value using up and down arrows or direct entry.

View source

Parent

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

Events

DNumberWang:OnValueChanged( number val )
Called when the number selector value is changed.

Methods

number DNumberWang:GetDecimals()
Returns the amount of decimal places allowed in the number selector, set by DNumberWang:SetDecimals
number DNumberWang:GetFloatValue()
We advise against using this. It may be changed or removed in a future update. Returns whatever is set by DNumberWang:SetFloatValue or 0.
DNumberWang:GetFraction( number val )
Returns a fraction representing the current number selector value to number selector min/max range ratio. If argument val is supplied, that number will be computed instead.
number DNumberWang:GetInterval()
Returns interval at which the up and down buttons change the current value.
number DNumberWang:GetMax()
Returns the maximum numeric value allowed by the number selector.
number DNumberWang:GetMin()
Returns the minimum numeric value allowed by the number selector.
Panel DNumberWang:GetTextArea()
We advise against using this. It may be changed or removed in a future update. This function returns the panel it is used on.
number DNumberWang:GetValue()
Returns the numeric value inside the number selector.
DNumberWang:HideWang()
Hides the number selector arrows.
DNumberWang:SetDecimals( number num )
Sets the amount of decimal places allowed in the number selector.
DNumberWang:SetFloatValue( number val )
We advise against using this. It may be changed or removed in a future update. Appears to do nothing.
DNumberWang:SetFraction( number val )
Sets the value of the number selector based on the given fraction number.
DNumberWang:SetInterval( number min )
Sets interval at which the up and down buttons change the current value.
DNumberWang:SetMax( number max )
Sets the maximum numeric value allowed by the number selector.
DNumberWang:SetMin( number min )
Sets the minimum numeric value allowed by the number selector.
DNumberWang:SetMinMax( number min, number max )
Sets the minimum and maximum value allowed by the number selector.
DNumberWang:SetValue( number val )
Sets the value of the DNumberWang and triggers DNumberWang:OnValueChanged

Example

Create the Number Wang with the minimum number being 0 and the max being 100

local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 250 ) frame:Center() frame:MakePopup() local Wang = vgui.Create("DNumberWang", frame) Wang:SetPos(85, 25) Wang:SetSize(45, 26) Wang:SetMin(0) Wang:SetMax(100) Wang.OnValueChanged = function(self) print(self:GetValue()) end
Output: