Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit 31a01c4

Browse files
committed
fixes for drag and drop reliability
1 parent 5ed46de commit 31a01c4

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

Objects/ACTIONBUTTON.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function ACTIONBUTTON:LoadData(spec, state)
7575
end
7676

7777
function ACTIONBUTTON:UpdateObjectVisibility(show)
78-
if self:HasAction() or #Neuron.macroDrag > 0 or show or self.showGrid or Neuron.buttonEditMode or Neuron.barEditMode or Neuron.bindingMode then
78+
if self:HasAction() or Neuron.dragging or show or self.showGrid or Neuron.buttonEditMode or Neuron.barEditMode or Neuron.bindingMode then
7979
self.isShown = true
8080
else
8181
self.isShown = false
@@ -572,10 +572,13 @@ function ACTIONBUTTON:ACTIONBAR_SHOWGRID()
572572
show = false
573573
end
574574

575+
Neuron.dragging = true
576+
575577
self:UpdateObjectVisibility(show)
576578
end
577579

578580
function ACTIONBUTTON:ACTIONBAR_HIDEGRID()
581+
Neuron.dragging = false
579582
self:UpdateObjectVisibility()
580583
end
581584

Objects/ACTIONBUTTON_DragAndDrop.lua

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
local ACTIONBUTTON = Neuron.ACTIONBUTTON
1111

1212
local macroDrag = {} --this is a table that holds onto the contents of the current macro being dragged
13-
Neuron.macroDrag = macroDrag --class level handle for checking during show/hide states
14-
1513
local macroCache = {} --this will hold onto any previous contents of our button
1614

1715
--------------------------------------
@@ -23,19 +21,21 @@ function ACTIONBUTTON:OnDragStart()
2321
return
2422
end
2523

26-
self.drag = nil --flag that says if it's ok to drag or not
24+
Neuron.dragging = true
25+
26+
local drag = nil --flag that says if it's ok to drag or not
2727

2828
if not self.barLock then
29-
self.drag = true
29+
drag = true
3030
elseif self.barLockAlt and IsAltKeyDown() then
31-
self.drag = true
31+
drag = true
3232
elseif self.barLockCtrl and IsControlKeyDown() then
33-
self.drag = true
33+
drag = true
3434
elseif self.barLockShift and IsShiftKeyDown() then
35-
self.drag = true
35+
drag = true
3636
end
3737

38-
if self.drag then
38+
if drag then
3939

4040
ClearCursor()
4141

@@ -75,7 +75,7 @@ function ACTIONBUTTON:OnReceiveDrag()
7575
wipe(macroCache)
7676
end
7777

78-
if macroDrag[1] then --checks to see if the thing we are placing is a Neuron created macro vs something from the spellbook
78+
if #macroDrag>0 then --checks to see if the thing we are placing is a Neuron created macro vs something from the spellbook
7979
self:PlaceMacro()
8080
elseif cursorType == "spell" then
8181
self:PlaceSpell(action1, action2, spellID)
@@ -107,14 +107,14 @@ function ACTIONBUTTON:OnReceiveDrag()
107107

108108
self:SetType()
109109
self:UpdateAll()
110-
self:UpdateCooldown() --clear any cooldowns that may be on the button now that the button is empty
111110

112-
if macroCache[1] then
111+
if #macroCache>0 then
113112
self:OnDragStart(macroCache) --If we picked up a new ability after dropping this one we have to manually call OnDragStart
114113
self:ACTIONBAR_SHOWGRID() --show the button grid if we have something picked up (i.e if macroDrag contains something)
115114
else
116115
SetCursor(nil)
117116
ClearCursor() --if we did not pick up a new spell, clear the cursor
117+
Neuron.dragging = false
118118
end
119119

120120
if NeuronObjectEditor and NeuronObjectEditor:IsVisible() then
@@ -124,20 +124,25 @@ end
124124

125125

126126
function ACTIONBUTTON:PostClick() --this is necessary because if you are daisy-chain dragging spells to the bar you wont be able to place the last one due to it not firing an OnReceiveDrag
127-
if macroDrag[1] then
127+
if #macroDrag>0 then
128128
self:OnReceiveDrag()
129129
end
130130
self:UpdateStatus()
131131
end
132132

133133
--we need to hook to the WorldFrame OnReceiveDrag and OnMouseDown so that we can "let go" of the spell when we drag it off the bar
134134
function ACTIONBUTTON:WorldFrame_OnReceiveDrag()
135-
if macroDrag[1] then --only do something if there's currently data in macroDrag. Otherwise it is just for normal Blizzard behavior
135+
if #macroDrag>0 then --only do something if there's currently data in macroDrag. Otherwise it is just for normal Blizzard behavior
136136
SetCursor(nil)
137137
ClearCursor()
138+
Neuron.dragging = false
138139
wipe(macroDrag)
139140
wipe(macroCache)
140141
end
142+
143+
for _,v in pairs(Neuron.BARIndex) do
144+
v:UpdateBarObjectVisibility()
145+
end
141146
end
142147
--------------------------------------
143148
--------------------------------------
@@ -202,7 +207,6 @@ function ACTIONBUTTON:PlaceMacro()
202207
self.data.macro_UseNote = macroDrag[6]
203208
self.data.macro_BlizzMacro = macroDrag[7]
204209
self.data.macro_EquipmentSet = macroDrag[8]
205-
206210
end
207211

208212
function ACTIONBUTTON:PlaceSpell(action1, action2, spellID)

0 commit comments

Comments
 (0)