Open and close spawn menu

Working on custom spawn menu (qmenu), and stuck on a problem.
How to open menu on press button and close on release button?

[LUA]
function QMenu()
BackGroundProps = vgui.Create(“DFrame”)
BackGroundProps:SetPos(ScrW().05,ScrH().05)
BackGroundProps:SetSize(ScrW().625,ScrH().9)
BackGroundProps:MakePopup()
BackGroundProps:SetDraggable(false)
BackGroundProps:ShowCloseButton(true)
BackGroundProps:SetTitle(“QMenu”)
end

function GM:OnSpawnMenuOpen()
Q = QMenu()
end

function GM:OnSpawnMenuClose()
if Q and Q:IsValid() then Q:Close() end
end

[/LUA]

Any suggestions please?



function GM:OnSpawnMenuOpen()
	If ( !IsValid( BackGroundProps ) ) then QMenu()  return end
BackGroundProps:SetVisible( true )
end


function GM:OnSpawnMenuClose()
	If ( !IsValid( BackGroundProps ) ) then  return end
BackGroundProps:SetVisible( false )
end

You aren’t even returning anything from QMenu to assign to Q.

Thanks