Hello, I'm having an annoying problem with MakePopup(), it works well, wiki says it automatically calls SetKeyboardInputEnabled and SetMouseInputEnabled, and that allows you to interact with elements inside it like TextEntries, when you press F3, you can interact with VGUI elements (I guess that's a kind of gui.EnableScreenClicker)
The problem is that you can't leave MakePopup(), you can call SetMouseInputEnabled to false again in order to recover mouse input
But after running that function, you won't be allowed again to get control over that panel until you set true SetMouseInputEnabled
What's the deal about that? Is that if you call this function again to true, you will once again lose access again to the cursor, even gui.EnableScreenClicker will be ignored
Even trying to KillFocus or request over other panels to request those inputs won't work at all
My code
local PANEL = {}
local usesPopup = true
local disableInput = true
function PANEL:Init()
self:SetSize(600,200)
self:SetPos(16,16)
self:SetTitle("")
self:ShowCloseButton(false)
self.Title = vgui.Create("DLabelEditable", self)
self.Title:SetPos(4,4)
self.Title:SetFont("DermaDefault")
self.Title:SetText("Test Agenda")
self.Title.OnLabelTextChanged = function(txt)
self:UpdateTitle(txt)
end
end
function PANEL:UpdateTitle(txt)
if (disableInput) then
self:SetMouseInputEnabled(false)
self:SetKeyboardInputEnabled(false)
end
end
function PANEL:OnMousePressed(ms)
local x,y = self:ScreenToLocal(gui.MouseX(), gui.MouseY())
if (ms == MOUSE_LEFT && y < 32) then
self.Title:DoDoubleClick()
if (usesPopup) then
self:MakePopup()
end
end
end
function PANEL:Paint(w,h)
surface.SetDrawColor(0, 0, 0, 100)
surface.DrawRect(0,0,w,h)
end
function PANEL:Setup()
end
function PANEL:PerformLayout(w,h)
self.Title:SetPos(8,4)
self.Title:SetSize(w - 24, 24)
end
vgui.Register("gAgenda", PANEL, "DFrame")
if IsValid(AGENDA) then
AGENDA:Remove()
end
AGENDA = vgui.Create("gAgenda")
As you can see, I'm trying to create an editable title, if i don't call MakePopup(), i won't be able to edit the editablelabel, if i don't disable input, i won't be able to exit from the panel, even if i'm not editing anymore, my expected behaviour would be me being able to disable cursor with F3 and then being able to press on the label again
I can do a hacky solution as removing the panel after UpdateTitle and creating it back again...But come on, there MUST BE a real way to get an inverse MakePopup function, even more it should be documented in wiki
Thanks everybody
I've ended up by manually simulation how input works, withing bounds and mousecapture, I hope someday we find a way to inverse makepopup
Sorry, you need to Log In to post a reply to this thread.