Hi I am trying to make a context menu esque panel, it will have options and such for my gamemode
I am having trouble making it so the mouse moves freely on the screen when I open the panel
[CODE]
pContextOpenTime = 0.2
pContextWidth = 200
pButtonHeight = 50
pContextHeight = 300
pContextPadding = 10
propContextPanel = vgui.Create( "DPanel" )
propContextPanel:SetPos( ScrW()-pContextWidth, ScrH() + pContextHeight )
propContextPanel:SetSize( pContextWidth, pContextHeight )
propContextPanel:SetMouseInputEnabled( true )
propContextPanel:MouseCapture( true )
propContextPanel:SetFocusTopLevel()
local pButtTest = vgui.Create( "DButton", propContextPanel)
pButtTest:SetText( "Test Button" )
pButtTest:SetPos( pContextPadding, pContextPadding )
pButtTest:SetSize( pContextWidth - 2*pContextPadding, pButtonHeight)
pButtTest.DoClick = function()
print( "clicked" )
end
hook.Add( "OnContextMenuOpen", "Display the prop context menu", function()
if( LocalPlayer():Team() != TEAM_PROPS ) then return end
timer.Destroy( "hide prop context menu" )
propContextPanel:MoveTo(ScrW()-pContextWidth,ScrH()-pContextHeight,pContextOpenTime,0,1)
propContextPanel:SetVisible( true )
end )
hook.Add( "OnContextMenuClose", "Close the prop context menu", function()
if( LocalPlayer():Team() != TEAM_PROPS ) then return end
propContextPanel:MoveTo(ScrW()-pContextWidth,ScrH()+pContextHeight,pContextOpenTime,0,1)
timer.Create("hide prop context menu",pContextOpenTime, 1, function ()
propContextPanel:SetVisible( false )
end )
end )
[/CODE]
I'm sure it's something simple I'm missing.
edit: also any tips on vgui or code style would be great, thanks.
:MakePopup()
And a tip: Making global variables for stuff you don't need to access outside the file is stupid.
Sorry, you need to Log In to post a reply to this thread.