mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-21 23:26:56 +00:00
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:
+8
-6
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user