Derma: Why do these buttons disappear when the list is there?
0 replies, posted
I am using derma to create a window that opens files and I am aware that it's not working. Right now, I'm trying to figure out why my open and cancel buttons only show up when my DListView called DermaListView is present. When I comment it out, the buttons show up just fine. I checked the positions of the buttons and list and they don't overlap. Same with the sizes. Here is my code:
[lua]
function FileDialog() -- Check if you need parentheses after open, cancel, and up
DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetSize( 600, 800 )
DermaPanel:SetTitle( "Open File" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
-- path = Computer -- Un-comment when you know default text works
local DermaTextPath = vgui.Create( "DTextEntry", DermaPanel)
DermaTextPath:SetValue( "You may only open files within your Garry's Mod base folder. (garrysmod/garrysmod/...)" ) -- Test if this works
DermaTextPath:SetPos( 25, 25 )
DermaTextPath:SetWide( 510 )
DermaTextPath:SetTall( 20 )
DermaTextPath:SetEnterAllowed( true )
function DermaTextPath:OnEnter()
path = DermaTextPath:GetValue()
end
local DermaListView = vgui.Create( "DListView" )
DermaListView:SetParent( DermaPanel )
DermaListView:SetPos( 25, 100 )
DermaListView:SetSize( 550, 625 )
DermaListView:SetMultiSelect( false )
DermaListView:AddColumn( "Name" )
Msg(file.Find(path)) -- Delete this after you see it printed
for k,v in pairs(file.Find(path)) do -- Make sure this works
DermaListView:AddLine(v) -- Make sure v works
end
local DermaButtonOpen = vgui.Create( "DButton")
DermaButtonOpen:SetParent( DermaPanel )
DermaButtonOpen:SetDisabled( false )
DermaButtonOpen:SetText( "Open" )
DermaButtonOpen:SetPos( 475, 750 )
DermaButtonOpen:SetSize( 100, 25 )
function DermaButtonOpen:DoClick()
RunConsoleCommand( "open" )
end
local DermaButtonCancel = vgui.Create( "DButton", DermaPanel)
DermaButtonCancel:SetText( "Cancel" )
DermaButtonCancel:SetPos( 25, 750 )
DermaButtonCancel:SetSize( 100, 25 )
function DermaButtonCancel:DoClick()
RunConsoleCommand( "cancel" )
end
local DermaButtonUp = vgui.Create( "DSysButton", DermaPanel )
DermaButtonUp:SetPos( 530, 25 )
DermaButtonUp:SetSize( 20, 20 )
DermaButtonUp:SetType( "up" )
function DermaButtonUp:DoClick()
RunConsoleCommand( "up" )
end
end
concommand.Add( "FileDialog", FileDialog )
function up( path )
path = path .. "../" -- Need to test if this will update in text box instantly after you replace the default text if it works
Msg( path )
end
concommand.Add( "up", up )
function open(path)
print(file.Read(path))
end
concommand.Add( "open", open )
function cancel()
DermaPanel:Remove()
end
concommand.Add( "cancel", cancel )
[/lua]
Never mind guys, I already got help for this problem.
Sorry, you need to Log In to post a reply to this thread.