api: cache mouse-drag functions

This commit is contained in:
shagu
2019-04-21 17:43:50 +02:00
parent ca2cf71d04
commit 7fd1ae5489
+6 -13
View File
@@ -454,6 +454,8 @@ end
-- 'name' [frame/string] Name of the Frame that should be movable
-- 'addon' [string] Addon that must be loaded before being able to access the frame
-- 'blacklist' [table] A list of frames that should be deactivated for mouse usage
local function MoveMouseDown() this:StartMoving() end
local function MoveMouseUp() this:StopMovingOrSizing() end
function pfUI.api.EnableMovable(name, addon, blacklist)
if addon then
local scan = CreateFrame("Frame")
@@ -470,13 +472,9 @@ function pfUI.api.EnableMovable(name, addon, blacklist)
frame:SetMovable(true)
frame:EnableMouse(true)
frame:SetScript("OnMouseDown",function()
this:StartMoving()
end)
frame:SetScript("OnMouseDown", MoveMouseDown)
frame:SetScript("OnMouseUp", MoveMouseUp)
frame:SetScript("OnMouseUp",function()
this:StopMovingOrSizing()
end)
this:UnregisterAllEvents()
end
end)
@@ -491,13 +489,8 @@ function pfUI.api.EnableMovable(name, addon, blacklist)
if type(name) == "string" then frame = _G[name] end
frame:SetMovable(true)
frame:EnableMouse(true)
frame:SetScript("OnMouseDown",function()
this:StartMoving()
end)
frame:SetScript("OnMouseUp",function()
this:StopMovingOrSizing()
end)
frame:SetScript("OnMouseDown", MoveMouseDown)
frame:SetScript("OnMouseUp", MoveMouseUp)
end
end