Hey there.
I've got a small problem with a piece of code.
Ive got a MainObject (MainObj) and on MouseEnter a ChildObject (ChildObj) with a Button in it (ChildButton) should show up. -Works fine so far
Now on MouseExit the ChildObject should get hidden again. - Works fine too
Now The Problem:
If i MouseEnter the ChildButton to click it, the MainObj registeres a MouseExit. This leads to a spamming of Hide/Show of the ChildObject. Is there anything i can do about this, so that the ChildObject keeps being open and only hides if i MouseExit the MainObj?
Lua Code:
local MainObj = WINDOW_MANAGER:CreateControl("MainObj",TLW,CT_CONTROL)
MainObj:SetDimensions(200,100)
MainObj:SetAnchor(TOPLEFT,GuiRoot,TOPLEFT,0,0)
MainObj:SetMouseEnabled(true)
MainObj:SetHandler("OnMouseEnter",function()
ChildObj:SetHidden(true)
end)
MainObj:SetHandler("OnMouseExit",function()
ChildObj:SetHidden(true)
end)
local ChildObj = WINDOW_MANAGER:CreateControl("ChildObj",MainObj,CT_TEXTURE)
ChildObj:SetDimensions(ChildObj:GetParent():GetWidth(),ChildObj:GetParent():GetHeight()/2)
ChildObj:SetAnchor(BOTTOMLEFT,MainObj,BOTTOMLEFT,0,0)
ChildObj:SetTexture("")
ChildObj:SetDrawLayer(4)
ChildObj:SetColor(0,0,0,0.8)
ChildObj:SetHidden(true)
local ChildButton = WINDOW_MANAGER:CreateControl("ChildButton",ChildObj,CT_BUTTON)
ChildButton:SetDimensions(ChildButton:GetParent():GetHeight()-5,ChildButton:GetParent():GetHeight()-5)
ChildButton:SetAnchor(LEFT,ChildObj,LEFT,5,0)
ChildButton:SetNormalTexture("")
ChildButton:SetDrawLayer(4)
ChildButton:SetHandler("OnClicked",function()
d("Clicked")
end)