• Derma Help!
    2 replies, posted
Ok im making a To-Do List and i want some way to add and remove to do items, i have only attempted to add the adding item but it isnt working?!?! any help guys for both? heres my code [CODE]concommand.Add( "todo", function() local menu = vgui.Create("DFrame") menu:SetTitle("To Do List") menu:SetSize(400, 300) menu:Center() menu:MakePopup() local AppList = vgui.Create( "DListView", menu ) AppList:SetMultiSelect( false ) AppList:AddColumn( "Item" ) AppList:AddColumn( "Date To Finish By" ) AppList:SetPos ( 0, 80 ) AppList:SetSize(400, 220) AppList:AddLine( Name , Date ) local TextEntry = vgui.Create( "DTextEntry", menu ) TextEntry:SetPos( 28, 27 ) TextEntry:SetSize( 75, 45 ) TextEntry:SetText( "Name" ) TextEntry.OnEnter = function( self ) Name= self:GetValue() end local TextEntry1 = vgui.Create( "DTextEntry", menu ) TextEntry1:SetPos( 75, 27 ) TextEntry1:SetSize( 90, 45 ) TextEntry1:SetText( "Date (DD/MM/YY)" ) TextEntry1.OnEnter = function( self ) Date= self:GetValue() end end)[/CODE] Thanks In Advance!
The reason it's not working is that you are only setting the variable. After you set the variable, nothing uses it. Here's a version I made that hopefully explains: [lua] local date, name local main, AppList, TextEntry, TextEntry1 -- so we can access them in functions above where they are created local function addline() if date and name then -- check if both date and name are not nil AppList:AddLine(name, date) -- add the line date, name = nil, nil -- get rid of the vars end end menu = vgui.Create("DFrame") menu:SetTitle("To Do List") menu:SetSize(400, 300) menu:Center() menu:SetVisible(false) -- Disable for now AppList = vgui.Create("DListView", menu) AppList:SetMultiSelect(false) AppList:AddColumn("Item") AppList:AddColumn("Date To Finish By") AppList:SetPos (0, 80) AppList:SetSize(400, 220) TextEntry = vgui.Create("DTextEntry", menu) TextEntry:SetPos(28, 27) TextEntry:SetSize(75, 45) TextEntry:SetText("Name") TextEntry.OnEnter = function(self) name = self:GetValue() addline() -- check if we can add a line end TextEntry1 = vgui.Create("DTextEntry", menu) TextEntry1:SetPos(75, 27) TextEntry1:SetSize(90, 45) TextEntry1:SetText("Date (DD/MM/YY)") TextEntry1.OnEnter = function(self) date = self:GetValue() addline() -- check if we can add a line end concommand.Add("todo", function() menu:MakePopup() -- show our panel end, nil, "Show todo menu") [/lua]
Thanks !
Sorry, you need to Log In to post a reply to this thread.