Fix draggable functionality
Tek Hudson [01-06-20 - 12:08]
Fix draggable functionality
diff --git a/DruidBar.lua b/DruidBar.lua
index a978582..1d2e691 100644
--- a/DruidBar.lua
+++ b/DruidBar.lua
@@ -306,12 +306,19 @@ function DruidBar_MainGraphics()
DruidBar_Anchored = nil;
end
+ -- Set the position lock and dragability
if DruidBarKey.Lock then
dbarShow(DruidBarDontMove);
DruidBarFrame:EnableMouse(0);
+ DruidBarFrame:SetMovable(false)
+ DruidBarFrame:RegisterForDrag()
else
dbarHide(DruidBarDontMove);
DruidBarFrame:EnableMouse(1);
+ DruidBarFrame:SetMovable(true)
+ DruidBarFrame:RegisterForDrag("LeftButton")
+ DruidBarFrame:SetScript("OnDragStart", DruidBarFrame.StartMoving)
+ DruidBarFrame:SetScript("OnDragStop", DruidBarFrame.StopMovingOrSizing)
end
else
dbarHide(DruidBarFrame);
diff --git a/DruidBar.xml b/DruidBar.xml
index 511591e..119813b 100644
--- a/DruidBar.xml
+++ b/DruidBar.xml
@@ -7,7 +7,7 @@
<GameTooltip name="DBarSpellCatch" frameStrata="TOOLTIP" inherits="GameTooltipTemplate"/>
- <Frame name="DruidBarFrame" hidden="true" frameStrata="BACKGROUND" enableMouse="true" movable="true" parent="UIParent">
+ <Frame name="DruidBarFrame" hidden="true" frameStrata="BACKGROUND" enableMouse="true" parent="UIParent">
<Size>
<AbsDimension x="170" y="18"/>
</Size>
@@ -102,35 +102,9 @@
<OnLoad>
self:SetFrameLevel("1");
</OnLoad>
- <OnMouseDown>
- if button == "LeftButton" and not self.isMoving then
- self:GetParent():StartMoving();
- self.isMoving = true;
- end
- </OnMouseDown>
- <OnMouseUp>
- if button == "LeftButton" and self.isMoving then
- self:GetParent():StopMovingOrSizing();
- self.isMoving = false;
- end
- </OnMouseUp>
- <OnHide>
- if self.isMoving then
- self:GetParent():StopMovingOrSizing();
- self.isMoving = false;
- end
- </OnHide>
</Scripts>
</StatusBar>
</Frames>
-
- <Scripts>
- <OnLoad>
- self:RegisterForDrag("LeftButton");
- </OnLoad>
- <OnDragStart>self:StartMoving();</OnDragStart>
- <OnDragStop>self:StopMovingOrSizing();</OnDragStop>
- </Scripts>
</Frame>
<Frame name="DruidBarUpdateFrame">
@@ -155,7 +129,7 @@
</Anchors>
</Button>
- <Frame name="DruidBarReplaceText" frameStrata="LOW" enableMouse="true" movable="true" parent="UIParent" hidden="true">
+ <Frame name="DruidBarReplaceText" frameStrata="LOW" enableMouse="true" movable="false" parent="UIParent" hidden="true">
<Size>
<AbsDimension x="120" y="10"/>
</Size>