Having issues with DFrame and DButton, SetParent() not working properly..
3 replies, posted
I am trying to create a Derma Menu, but for some odd reason I can't set the DFrame as Parent to the DButton.
Screenshot:
[IMG]http://oi61.tinypic.com/29wx0rd.jpg[/IMG]
Now the button only shows when I set [code]local b1 = vgui.Create( 'DButton', 'base' )//Only when the [I]base[/I] is in quotes the button shows up, without quotes it doesn't[/code]
Here's the code I created:
[code]function ph_tm_p1()
local base = vgui.Create( 'DFrame' ) //Menu Frame
base:SetSize(176, 571)
base:SetPos(1728, 208)
base:SetTitle('Taunts')
base:SetDeleteOnClose(false)
base:ShowCloseButton(false)
base:MakePopup()
local b1 = vgui.Create( 'DButton', 'base' ) //Button1
b1:SetSize(150, 33)
b1:SetPos(1741, 241)
b1:SetText('Button1')
b1.DoClick = function() end
end
concommand.Add("phtm",ph_tm_p1)[/code]
I even tried:[code]b1:SetParent( base ) //Button didn't show.
b1:SetParent( "base" ) //Button showed, but wasn't a part of the DFrame.[/code]
Could you give me a hint about he mistake I am doing?
Change: [CODE]local b1 = vgui.Create( 'DButton', 'base' )[/CODE]
To: [CODE]local b1 = vgui.Create( 'DButton', base )[/CODE]
The reason why the button doesn't show up is because of your button positon(x&y).
Set it to 0,0 and then you can edit it from there.
[editline]10th October 2014[/editline]
Also it's a really bad way to use pixels based positions if you don't want it in the top right.
Take a look at ScrW() and ScrH()
[QUOTE=CodingBeast;46198589]Change: [CODE]local b1 = vgui.Create( 'DButton', 'base' )[/CODE]
To: [CODE]local b1 = vgui.Create( 'DButton', base )[/CODE]
The reason why the button doesn't show up is because of your button positon(x&y).
Set it to 0,0 and then you can edit it from there.[/QUOTE]
Thank you! Much appreciated!
I want it to be in the middle of the Right side of the screen, so yea'.. if you know how I appreciate the help.
Edit: How can I limit that the player can open the menu once?
[code]
local opened = false
function ph_tm_p1()
if ( opened ) then return end
opened = true
local base = vgui.Create( 'DFrame' ) //Menu Frame
base:SetSize(176, 571)
base:SetPos(1728, 208)
base:SetTitle('Taunts')
base:SetDeleteOnClose(false)
base:ShowCloseButton(false)
base:MakePopup()
local b1 = vgui.Create( 'DButton', base ) //Button1
b1:SetSize(150, 33)
b1:SetPos(1741, 241)
b1:SetText('Button1')
b1.DoClick = function() end
end
concommand.Add("phtm",ph_tm_p1)[/code]
Sorry, you need to Log In to post a reply to this thread.