core: switch from mousedown to drag functions

Due to crashes/freezes while moving some frames, one possible
reason could be that pfUI was using OnMouseDown and OnMouseUp
to run its frame-moving code. I have noticed better performance
when using the intended functions, OnDragStart and OnDragStop
to move frames.

This commit changes every occurrence of such functions and splits
drag and click into seperate functions where required.
This commit is contained in:
shagu
2022-05-07 21:35:52 +02:00
parent c72c61c133
commit 0214eebf36
10 changed files with 59 additions and 47 deletions
+8 -6
View File
@@ -526,8 +526,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
local function OnDragStart() this:StartMoving() end
local function OnDragStop() this:StopMovingOrSizing() end
function pfUI.api.EnableMovable(name, addon, blacklist)
if addon then
local scan = CreateFrame("Frame")
@@ -544,8 +544,9 @@ function pfUI.api.EnableMovable(name, addon, blacklist)
frame:SetMovable(true)
frame:EnableMouse(true)
frame:SetScript("OnMouseDown", MoveMouseDown)
frame:SetScript("OnMouseUp", MoveMouseUp)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", OnDragStart)
frame:SetScript("OnDragStop", OnDragStop)
this:UnregisterAllEvents()
end
@@ -561,8 +562,9 @@ 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", MoveMouseDown)
frame:SetScript("OnMouseUp", MoveMouseUp)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", OnDragStart)
frame:SetScript("OnDragStop", OnDragStop)
end
end