Hi,
I was rewriting one of my addons trying to implement a custom frame instead of the standard LDB.
Everything works just fine but I was wondering if it is possible to use an onLeave codition to close it.
The skeleton code is something like this (shorter than the full code):
Lua Code:
local ADDON = ...
local Menu = CreateFrame('Frame', nil, UIParent)
Menu:SetClampedToScreen(true)
Menu:SetSize(100,100)
Menu:Hide()
-- Menu:SetScript('OnLeave', OnLeave)
Menu:SetBackdrop({
bgFile = "Interface/DialogFrame/UI-DialogBox-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 32, edgeSize = 16,
insets = { left = 5, right = 5, top = 5, bottom = 5 }
})
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local dataobj = ldb:NewDataObject(ADDON , {
type = "data source",
icon = "Interface\\Addons\\"..ADDON.."\\icon.tga",
text = "Test Only"
})
dataobj.OnClick = function(self, button)
if button == "LeftButton" then
if(Menu:IsShown()) then
Menu:Hide()
else
-- position code taken from Broker_Equipment by p3lim
Menu:ClearAllPoints()
Menu:SetPoint('TOP', self, 'BOTTOM') -- temporary anchor
local sideAnchor = ''
if(Menu:GetRight() > GetScreenWidth()) then
sideAnchor = 'RIGHT'
elseif(Menu:GetLeft() <= 0) then
sideAnchor = 'LEFT'
end
Menu:ClearAllPoints()
if(Menu:GetBottom() <= 0) then
Menu:SetPoint('BOTTOM' .. sideAnchor, self, 'TOP' .. sideAnchor)
else
Menu:SetPoint('TOP' .. sideAnchor, self, 'BOTTOM' .. sideAnchor)
end
Menu:Show()
end
end
end
I thought a simple:
Lua Code:
Menu:SetScript('OnLeave', Menu:Hide())
was ok to hide the frame when not hovering on it, but I was wrong
So now I ask:
Is there a simple way to accomplish this and prevent the fact the frame remains open until someone clicks the bar again ?
Thanks very much for your input.
P.s.
Actually the Tooltip is this: