DTextEntry scrollbar or DPanelList text table <- HELP

Hello FP’ers!

I was wondering If you could help me with solving my scrollbar problem.
I created a Derma menu, but one of the text tables is too long and falls off, but no scrollbar appears, and since


EnableVerticalScrollbar( true ) 

only works in DPanelList, I’m stuck.

So could anybody tell me how to create a scrollbar into a DTextEntry, or how to add a text table to a DPanelList?

The text table looks like this:


local text = {}
     text[1] = ( "Cadet (rank 1)
")
     text[2] = ( "Tag [G4L]Yourname
" )
     text[3] = ( "For anyone who is a member.
" )
     text[4] = ( "Everybody can use this tag without asking.
" )
     text[5] = ( "It shows your proud of G4L, and so are we at you when you wear this!
" )
     text[6] = ( "
" )
     text[7] = ( "Captain (rank 2)
" )
     text[8] = ( "Tag [G4L-C2]Adminname
" )
     text[9] = ( "Simply achieved by posting a bit and/or earning slight trust and by showing effort that you want to be a part of us.
" )
     text[10] = ( "Slight power on the servers./n" )
     text[11] = ( "Is not be relied on to do anything important./n" )
     text[12] = ( "Very basic server commands.
" )
     text[13] = ( "
" )
     text[14] = ( "Major (rank 3)
" )
     text[15] = ( "Tag [G4L-M3]Adminname
" )
     text[16] = ( "Achieved by proving your loyalty
" )
     text[17] = ( "Moderate power on the servers, is allowed to be present at admin meetings.
" )
     text[18] = ( "Can vote for a cadet to become captain. (Will be made by Field Marshal or Higher permission, must have shown himself in our community by posting on the forums and playing on the servers)
" )
     text[19] = ( "Average power, has some more punishment commands.
" )
     text[20] = ( "Primary working class of G4L
" )
     text[21] = ( "" )
     text[22] = ( "
" )
     text[23] = ( "General (rank 4)
" )
     text[24] = ( "Tag [G4L-G4]Adminname
" )
     text[25] = ( "Achieved by doing great work and has to be voted up by 80% of ranks 3-5 Mastermind decides when voting will take place.
" )
     text[26] = ( "High power on the servers, must be present at admin meetings.
" )
     text[27] = ( "Can promote people from Cadet to Captain to Major.
" )
     text[28] = ( "High power on the servers, has access to almost all commands.
" )
     text[29] = ( "Secondary working class of G4L, works on more sensitive projects.
" )
     text[30] = ( "" )
     text[31] = ( "
" )
     text[32] = ( "Field Marshal (rank 5)
" )
     text[33] = ( "Tag [G4L-FM]Adminname
" )
     text[34] = ( "Hand picked by Mastermind.
" )
     text[35] = ( "High amount of power on the servers, must be present at admin meetings.
" )
     text[36] = ( "Can promote people from Cadet to Captain to Major.
" )
     text[37] = ( "Has access to all commands, with exception for server execute commands.
" )
     text[38] = ( "Decides in the most important decisions and helps rule Gamers4Life.
" )
     text[39] = ( "" )
     text[40] = ( "
" )
     text[41] = ( "Head Admin
" )
     text[42] = ( "(Extra Rank)
" )
     text[43] = ( "The one put in charge over all the other admins and ranks. (Except VP and PR)
" )
     text[44] = ( "Has all amount of power you can have inside G4L, helps organize admin meetings.
" )
     text[45] = ( "Nothing that he doesn't know.
" )
     text[46] = ( "Has all power you can get inside Gamers4Life.
" )
     text[47] = ( "" )
     text[48] = ( "" )
     text[49] = ( "
" )
     text[50] = ( "Vice-President
" )
     text[51] = ( "Tag [G4L-VP]Gamerlv
" )
     text[52] = ( "Ultimate power over G4L. -> TEH (almost goddiest) GOD :O
" )
     text[53] = ( "Has all avalible powers.
" )
     text[54] = ( "
" )
     text[55] = ( "President
" )
     text[56] = ( "Tag [G4L-PR]Mastermind
" )
     text[57] = ( "Ultimate power over G4L. -> TEH GOD :O
" )
     text[58] = ( "Has all avalible powers.
" )
     text[59] = ( "
" )
     text[60] = ( "Major+ has Reserved slot access.
" )

Thanks in advance!

Mr. Bumpy billy :smiley:

Alright, so I have come this far.
I made a DPanelList:



local adminpanel = vgui.Create( "DPanelList", infomenu )
adminpanel:SetPos( 10, 50 )  
adminpanel:SetSize( 550, 480 )  
adminpanel:SetSpacing(5)  
adminpanel:EnableHorizontal( false )
adminpanel:EnableVerticalScrollbar( true )
adminpanel.Paint = function() -- Paint function
    surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel
    surface.DrawRect( 0, 0, adminpanel:GetWide(), adminpanel:GetTall() ) -- Draw the rect
end


then a DLabel for the text, that refers to the above (first post) ‘text’ table for its content


for k,v in pairs(text) do  
local label = vgui.Create("DLabel", adminpanel)
    
    label:SetText(v)
    label:SizeToContents()

end

Now the text is in the right place, in the right tab, and showing, but all the lines are on one line.
It appears to be ignoring the newlines in the table, how would I fix that?

Remove the newlines, add

adminpanel:AddItem(label)

in the loop.

Using a label? are you being serious, that would look like pure turd.

Use this instead **[DForm

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=DForm)**

I tried doing as you said, this is the new code:


local adminpanel = vgui.Create( "DPanelList", infomenu )
adminpanel:SetPos( 10, 50 )  
adminpanel:SetSize( 550, 480 )  
adminpanel:SetSpacing(5)  
adminpanel:EnableHorizontal( false )
adminpanel:EnableVerticalScrollbar( true )
adminpanel:AddItem(label)
adminpanel.Paint = function() -- Paint function
    surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel
    surface.DrawRect( 0, 0, adminpanel:GetWide(), adminpanel:GetTall() ) -- Draw the rect
end

I have removed all newlines, tough the result stays the same as before:

http://pictures.gamers4life.org/images/gmod.png

Please help!
Thanks.

Are you creating a new DPanelList for every label?

Anyway, I found myself having formatting issues with those things and labels like 3 days ago, here’s my fix:

[lua] self.DetailsDescPanel = vgui.Create(“DPanelList”, self.DetailsPanel)
self.DetailsDescPanel:SetPos(5, 150)
self.DetailsDescPanel:SetSize(190,200)
self.DetailsDescPanel.Paint = function() end

self.DetailsDescPanel.SetText = function(me,text)
    me:Clear()
    local txt = markup.Parse("&lt;font=DefaultBold&gt;&lt;colour=255,255,255,255&gt;"..text.."&lt;/colour&gt;&lt;/font&gt;", self.DetailsPanel:GetWide() - 15)
    
    local prefix = Label("Description: ")
    prefix:SetFont("DefaultBold")
    
    me:AddItem(postfix)
    
    for k,v in pairs(txt.blocks) do
        local lbl = Label(v.text, self.DetailsDescPanel)
        lbl:SetTall(v.height)
        lbl:SetFont(v.font)
        
        self.DetailsDescPanel:AddItem(lbl)
    end
end[/lua]

You’re probably going to have to edit it a bit to suit your needs, since this was made for one long string at a time. markup.Parse’s second argument is the max width of the text, for wrapping etc.

Ive edited your piece of code to my needs, I hope Ive done it right:


    adminpanel = vgui.Create("DPanelList", infomenu)
    adminpanel:SetPos(10, 50)
    adminpanel:SetSize(550,480)
    adminpanel.Paint = function() end
    
    adminpanel.SetText = function(me,text)
        me:Clear()
        local txt = markup.Parse("<font=DefaultBold><colour=255,255,255,255>"..text.."</colour></font>", infomenu:GetWide() - 15)
        
        local prefix = Label("Description: SUMTIN ")
        prefix:SetFont("DefaultBold")
        
        me:AddItem(postfix)
        
        for k,v in pairs(txt.blocks) do
            local label = Label(v.text, adminpanel)
            label:SetTall(v.height)
            label:SetFont(v.font)
            
            adminpanel:AddItem(label)
        end
    end

But now I have the same effect, except that I dont have a ‘black’ background but a ‘grey’ one.

[lua]
local Solution = vgui.Create( “DPanel”, YOURPANEL )
Solution:SetPos( 125, 50 )
Solution:SetSize( YOURPANEL:GetWide() - 25, YOURPANEL:GetTall() - 25 )
Solution.Paint = function()
local OurStringThing1 = “first piece”
local OurStringThing2 = “of string”
surface.SetFont( “default” )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( 50, 50 )
surface.DrawText( OurStringThing1 )

		surface.SetFont( "default" )   
		surface.SetTextColor( 255, 255, 255, 255 )   
		surface.SetTextPos( 50, 65 )   
		surface.DrawText( OurStringThing2 )
                   
                     And so on
  end

[/lua]

No…



 adminpanel.SetText = function(me,text)
        me:Clear()
        local txt = markup.Parse("<font=DefaultBold><colour=255,255,255,255>"..text.."</colour></font>", infomenu:GetWide() - 15)
        
        for k,v in pairs(txt.blocks) do
            local label = Label(v.text, adminpanel)
            label:SetTall(v.height)
            label:SetFont(v.font)
            
            adminpanel:AddItem(label)
        end
end

Other code had error, try this one.

[lua] local adminpanel = vgui.Create( “DPanelList”, infomenu )
adminpanel:SetPos( 10, 50 )
adminpanel:SetSize( 550, 480 )
adminpanel:SetSpacing( 1 )
adminpanel:EnableHorizontal( true )
adminpanel:EnableVerticalScrollbar( true )

 adminpanel.SetText = function(me,text)
    me:Clear()
    local txt = markup.Parse("&lt;font=DefaultBold&gt;&lt;colour=255,255,255,255&gt;"..text.."&lt;/colour&gt;&lt;/font&gt;", infomenu:GetWide() - 15)
    
    for k,v in pairs(txt.blocks) do
        local label = Label(v.text, adminpanel)
        label:SetTall(v.height)
        label:SetFont(v.font)
        
        adminpanel:AddItem(label)
    end

end[/lua]

I tried that, please excsue me if its wrong but I just woke up.
It doesn’t create any text.

I tested my code and it worked, you are doing it wrong.

Your code didnt do anything of what he wanted(if i read the thread right which i probbably have), Dave’s code should work, but you got to call adminpanel:SetText
adminpanel:SetText(“Test
Works!”)

Yours didn’t, mine had. Your method would result in a frikkin long file though.

That’s not what I want, I want to use a TABLE to get the text from, like stated in the first post.

Thanks for all your replies so far.

Just turn it into a long string ([[text here]])

It also supports newlines, even though you don’t need them. (These are done automatically on an actual newline, no need to do /n)

adminpanel:SetText(table.concat(text, “”))

You want a random line or all of them?

If you want all of them at the same time, I suggest this:


 
 DermaList = vgui.Create( "DPanelList", adminpanel )
DermaList:SetPos( 15, 35 )
DermaList:SetSize( 255, 60 )

 Text = vgui.Create( "DLabel", adminpanel )
Text:SetPos( 20, 40)
Text:SetText("lawls
lawls I know
Yea right.")
Text:SizeToContents( )

Whenever I try to use /n it actually prints “/n” not go to a new line.

It’s
not /n.