I have added a slider on my panel and I can't have the value in realtime I need alway to close and reopen my panel to get the value
Any Idea how I can have it in realtime ?
[lua]
function startframe() // the frame it will be set in.
local SizeNX = CreateClientConVar( "C_SizeX", "0", false, false)
local GetSizeX = SizeNX:GetInt()
local CAlpha = CreateClientConVar( "C_Alpha", "1", false, false)
local GetAlphaNo = CAlpha:GetFloat()
local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
DermaPanel:SetSize( GetSizeX + 210, 325 ) -- Size of the frame ( use half the width / height of your screen )
DermaPanel:SetPos( 300, 100 )
local Size_X, Size_Y = DermaPanel:GetSize( ) -- Get the size of the panel
local Title = "Size: (" .. tostring( Size_X ) .. ", " .. tostring( Size_Y ) .. ")" -- Set our title in a variable
DermaPanel:SetTitle( Title ) -- Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) -- Draggable by mouse?
DermaPanel:ShowCloseButton( true ) -- Show the close button?
DermaPanel:MakePopup( ) -- Show the frame
DermaPanel.Paint = function()
draw.RoundedBox( 2, 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall(), Color( 100, 100, 100, GetAlphaNo ) ) end
local NumSliderX = vgui.Create( "DNumSlider", DermaPanel )
NumSliderX:SetPos( 25,50 )
NumSliderX:SetWide( 150 )
NumSliderX:SetText( "Set Size X" )
NumSliderX:SetMin( 0 ) -- Minimum number of the slider
NumSliderX:SetMax( 512 ) -- Maximum number of the slider
NumSliderX:SetDecimals( 0 ) -- Sets a decimal. Zero means it's a whole number
NumSliderX:SetConVar( "C_SizeX" ) -- Set the convar
local NumSliderAlpha = vgui.Create( "DNumSlider", DermaPanel )
NumSliderAlpha:SetPos( 25,150 )
NumSliderAlpha:SetWide( 150 )
NumSliderAlpha:SetText( "Set Alpha" )
NumSliderAlpha:SetMin( 0 ) -- Minimum number of the slider
NumSliderAlpha:SetMax( 255 ) -- Maximum number of the slider
NumSliderAlpha:SetDecimals( 0 ) -- Sets a decimal. Zero means it's a whole number
NumSliderAlpha:SetConVar( "C_Alpha" ) -- Set the convar
end
concommand.Add("MyTestPanel",startframe,startframe)[/lua]
- snip -
Well, besides you needing to [url=http://www.facepunch.com/showthread.php?t=861899]stop creating global functions which should be LOCAL[/url], there is [url=http://wiki.garrysmod.com/?title=P.Think]Panel.Think[/url].
ah there is my missing thing, many thanks
Sorry, you need to Log In to post a reply to this thread.