• [BUG?] lua/vgui/dpanellist.lua:443: attempt to index field 'VBar' (a nil value)
    7 replies, posted
-snip, EnableVerticalScrollbar does exist?-
DPanelList is deprecated in GM13 in favour of DIconLayout and DLineLayout.
I probably shouldn't have snipped my OP - one of my questions was what I should switch to instead? DIconLayout doesn't seem right for me (since I'm modifying the chatbox here), and DLineLayout doesn't seem to exist?
Instead, you could consider docking a panel to a DScrollPanel. [b]Edit:[/b] I'm going to be screwing with Derma's to see if I can help figure it out for you. I'm just going off the Wiki and I'll need to do it myself to actually get it right. So forgive if the answers I'm giving are complete shit. :v:
Would using just a regular old dpanel do as the container for all of the lines of chat? That's my primary hesitation for making the jump from the deprecated panel, finding an appropriate replacement (preferably a panel that supports displaying multiple panels in a list fashion, with adding and removing support) Edit to your edit: Thanks for checking it out, I really appreciate it :)
I hope this is what you were asking for :v: [img]http://puu.sh/2j4wI/9b629dc455.png[/img] [lua] local self = {}; local function SafelyCall( fFunction, fOnSuccess, fOnError ) local mStatus, mError = pcall( fFunction ); if ( !mStatus ) then if ( fOnError ~= nil ) then fOnError( mStatus, mError ); end else if ( fOnSuccess ~= nil ) then fOnSuccess( mStatus, mError ); end end end function self.CreateUI( ) self.Width = 512; self.Height = 512; self.Padding = 4; self.TopMargin = 24; self.Frame = vgui.Create( "DFrame" ); self.Frame:SetTitle( ":v" ); self.Frame:SetSize( 512, 512 ); self.Frame:SetPos( ScrW() / 2 - self.Width / 2, ScrH() / 2 - self.Height / 2 ); self.Frame:SetSizable( true ); self.PropertySheet = vgui.Create( "DPropertySheet", self.Frame ); self.PropertySheet:SetPos( self.Padding, self.TopMargin + self.Padding ); self.PropertySheet:SetSize( self.Width - ( self.Padding * 2 ), self.Height - ( self.Padding * 2 ) - self.TopMargin ); -- Build dat sheets yo self.BuildSheets( ); for k, v in pairs( self.Sheet ) do v.Body:SizeToContents(); self.PropertySheet:AddSheet( v.Title or ("Page" .. k), v.Body, v.Icon or "icon16/page.png", false, false, v.Tooltip or nil ); end self.Frame:MakePopup(); end function self.BuildSheets( ) self.Sheet = {}; for iIndex = 1, 3, 1 do self.Sheet[iIndex] = {}; self.Sheet[iIndex].Title = "Derp"; self.Sheet[iIndex].Body = vgui.Create( "DScrollPanel" ); self.Sheet[iIndex].Component = {}; self.Sheet[iIndex].Component[1] = vgui.Create( "DPanel", self.Sheet[iIndex].Body ); self.Sheet[iIndex].Component[1]:SetSize( self.Width - self.Padding * 2, self.Height * 4 ); for i = 2, 1000, 1 do self.Sheet[iIndex].Component[ i ] = vgui.Create( "DLabel", self.Sheet[iIndex].Component[ 1 ] ); local component = self.Sheet[iIndex].Component[ i ]; component:SetText( ":v" ); component:SetPos( math.random( self.Width ), math.random( self.Height * 4 ) ); component:SetTextColor( Color( math.random( 255 ), math.random( 255 ), math.random( 255 ) ) ); end end end SafelyCall( self.CreateUI, nil, function( mStatus, mError ) print( "ERROR: " .. mError ); print( "DESTROYING EVERYTHING :V" ); if ( self.Frame ) then self.Frame:Close(); end table.Empty( self ); end );[/lua]
:v: In the end I was hoping I could be lazy and find some sort of drop-in replacement that worked almost exactly like DPanelList - but I guess it shouldn't be that hard to make my own methods for handling how the panel (and the parent scrollpanel) work as a chat box. I did, however, notice that DScrollPanel automatically creates a child Panel as the "canvas"... Would it make any difference if I used that instead of putting a DPanel in the DScrollPanel? And thank you for the awesome example :)
[QUOTE=tgp1994;39944940]:v: In the end I was hoping I could be lazy and find some sort of drop-in replacement that worked almost exactly like DPanelList - but I guess it shouldn't be that hard to make my own methods for handling how the panel (and the parent scrollpanel) work as a chat box. I did, however, notice that DScrollPanel automatically creates a child Panel as the "canvas"... Would it make any difference if I used that instead of putting a DPanel in the DScrollPanel? And thank you for the awesome example :)[/QUOTE] You could mess around with the child canvas to see if it's not being used for the scroll bar itself. Nothing beats actually getting to it and figuring it out. And you're welcome. :v:
Sorry, you need to Log In to post a reply to this thread.