diff --git a/api/api.lua b/api/api.lua index 64e7dd33..8bd1c98b 100644 --- a/api/api.lua +++ b/api/api.lua @@ -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