• Refresh a window
    7 replies, posted
Hey guys, Is there anyway of refreashing a DFrame window, or do i need to close and reopen a window?
Not sure if this will work but make a timer?
[QUOTE=tzahush;44823605]Hey guys, Is there anyway of refreashing a DFrame window, or do i need to close and reopen a window?[/QUOTE] Do you mean refresh the contents inside of the Panel? Show your code.
[QUOTE=brandonj4;44823925]Do you mean refresh the contents inside of the Panel? Show your code.[/QUOTE] currently i have no code, but im planning on changing some labels for example on the DFrame vgui.
I think DLabels refresh when they are changed.
I think he means updating the information when a value changes. What sort of value are you looking to "refresh"? (a player's ping, etc?)
normally I'd do something like this [LUA] local ThingsToRefresh = {} local base = vgui.Create( "DFrame" ) base:SetSize( 500, 500 ) base:Center() base.Refresh = function() for pnl, func in pairs( ThingsToRefresh ) do func( pnl ) end end local label = vgui.Create( "DLabel", base ) label:Dock( TOP ) label:SetText( "hello" ) ThingsToRefresh[label] = function( s ) s:SetText( math.random( 20 ) ) end local button = vgui.Create( "DButton", base ) button:Dock( BOTTOM ) button:SetText( "Refresh" ) button.DoClick = function() base:Refresh() end local amt = 0 ThingsToRefresh[button] = function( b ) amt = amt + 1; b:SetText( "Refreshed " .. amt .. " times" ) end [/LUA] or you'd make a function which deletes everything, then lays it out again. depends how far you need to go you get the idea
[QUOTE=rejax;44824975]normally I'd do something like this [LUA] local ThingsToRefresh = {} local base = vgui.Create( "DFrame" ) base:SetSize( 500, 500 ) base:Center() base.Refresh = function() for pnl, func in pairs( ThingsToRefresh ) do func( pnl ) end end local label = vgui.Create( "DLabel", base ) label:Dock( TOP ) label:SetText( "hello" ) ThingsToRefresh[label] = function( s ) s:SetText( math.random( 20 ) ) end local button = vgui.Create( "DButton", base ) button:Dock( BOTTOM ) button:SetText( "Refresh" ) button.DoClick = function() base:Refresh() end local amt = 0 ThingsToRefresh[button] = function( b ) amt = amt + 1; b:SetText( "Refreshed " .. amt .. " times" ) end [/LUA] or you'd make a function which deletes everything, then lays it out again. depends how far you need to go you get the idea[/QUOTE] for example adding and removing models.
Sorry, you need to Log In to post a reply to this thread.