• Some problems with DGrid
    9 replies, posted
Hi, I'm trying to build a new F4 menu for my server but i have big trouble understanding what i'm doing wrong in my logic. I'm trying to create the commands menu atm and i decided to use a DGrid to split my container into 4 parts... local PANEL_COMMANDS = {} function PANEL_COMMANDS:Init()   local containerWidth = CONTROLLER.MAIN_FRAME.MiddlePanel.Container:GetWide()   local containerHeight = CONTROLLER.MAIN_FRAME.MiddlePanel.Container:GetTall()   self.Paint = function(pnl,w,h) draw.RoundedBox(0,0,0,w,h, Color(0,0,255)) end   self:SetCols( 4 )   self:SetColWide( containerWidth / 4 )   for _, category in ipairs(SETTINGS.Commands) do     local currentCategory = vgui.Create("DPanel")     currentCategory:SetWidth(self:GetColWide())     currentCategory:SetHeight(containerHeight)     currentCategory.Label = vgui.Create("DLabel", currentCategory)     currentCategory.Label:SetText(category.categoryName)     currentCategory.Label:SetFont("MediumTitle")     currentCategory.Label:SetColor(Color(0,0,0))     currentCategory.Label:Dock(TOP)     currentCategory.Label:SetContentAlignment( 5 )     currentCategory.Label:SizeToContents()     currentCategory.Label.Paint = function(pnl,w,h) draw.RoundedBox(0,0,0,w,h, Color(255,0,255,125)) end     for _, cmd in ipairs(category.commands) do       local currentCmdButton = vgui.Create("DButton", currentCategory)       currentCmdButton:Dock( TOP )     end     currentCategory:InvalidateLayout( true )     currentCategory:SizeToChildren( true, true )     self:AddItem( currentCategory )   end end vgui.Register("PANEL_COMMANDS", PANEL_COMMANDS, "DGrid") Here is the panel code so far, and here is the output, I dont really understand what I'm doing wrong but the DPanel size is not changing at all... Seems to be default size :/ It might be a missunderstanding from me tho. Thanks in advance for any answer ^^'
Try moving everything inside a new function, inside your paint function check if your panel has not been initialized, call that function and then mark it as "Initialized" I feel that your issue comes from GetTall() and GetWide() not having the correct size, by initializing it inside paint hook, you're sure that you're initializing it after one frame Or just wrap your PANEL:Init() inside timer.Simple(0, function() end)
I don't understand your issue here...
... fml, you used the same method as my code above ? :/ The paint functions are useless here, i used them to show a difference between the elements... I tried the timer but not working... + the container is initialized far before the Grid... :/
This is all I did.
Problem is my DGrid height is NEVER changing, and you don't have this problem, I don't know what to do, i printer its size : height = 24 ... Isn't that default ?
It seems to me DGrid is completely retarded. But you can use what you said, SetRowHeight, and use the height you defined earlier. That should work, right?
It does works, thats the only way I found, but i hate dirty hacks, DGrid is supposed to adjust its size, yours do mine doesnt T_T
It doesn't adjust it's size, I tried it.
You copy pasted my code with little change and yours seems to adjust na?
Sorry, you need to Log In to post a reply to this thread.