This commit is contained in:
Salikh Gurgenidze
2025-11-21 13:52:29 +04:00
parent 5a0acbe70f
commit 61bfcc42bb
3 changed files with 56 additions and 10 deletions
+4 -10
View File
@@ -638,7 +638,8 @@
<!-- Container for item buttons -->
<Frame name="$parent_ItemContainer" enableMouse="true">
<!-- Set enableMouse to false so it does not intercept drag/drop meant for child item buttons -->
<Frame name="$parent_ItemContainer" enableMouse="false">
<Size>
<AbsDimension x="400" y="480"/>
</Size>
@@ -654,15 +655,8 @@
</TileSize>
<Color r="0" g="0" b="0" a="0.5"/>
</Backdrop>
<Scripts>
<OnMouseDown>
-- Clear search focus when clicking in item area
local searchBox = getglobal("Guda_BagFrame_SearchBar_SearchBox")
if searchBox then
searchBox:ClearFocus()
end
</OnMouseDown>
</Scripts>
<!-- Note: with enableMouse=false, OnMouseDown/OnReceiveDrag here would not fire;
child item buttons will handle mouse events directly. -->
</Frame>
</Frames>
+46
View File
@@ -108,6 +108,20 @@ function Guda_ItemButton_OnLoad(self)
iconFrame:Hide()
self.questIcon = iconFrame
end
-- Ensure the item button sits above its container backdrop and is mouse-enabled
local parent = self:GetParent()
if parent and parent.GetFrameLevel then
-- Place button above parent backdrop/mouse layer to reliably receive drops
local parentLevel = parent:GetFrameLevel()
if parentLevel and self:GetFrameLevel() <= parentLevel + 1 then
self:SetFrameLevel(parentLevel + 2)
end
end
if self.EnableMouse then
self:EnableMouse(true)
end
end
-- Set item data
@@ -484,6 +498,11 @@ function Guda_ItemButton_OnDragStart(self, button)
-- Only allow left button drag
if button == "LeftButton" and self.hasItem then
-- Ensure the global click catcher doesn't intercept the drag/drop
local cc = getglobal and getglobal("Guda_ClickCatcher")
if cc and cc.Hide and cc:IsShown() then
cc:Hide()
end
PickupContainerItem(self.bagID, self.slotID)
end
end
@@ -499,6 +518,33 @@ function Guda_ItemButton_OnReceiveDrag(self)
PickupContainerItem(self.bagID, self.slotID)
end
-- Handle mouse-up to emulate Blizzard drop behavior on 1.12 where OnReceiveDrag may not always fire
function Guda_ItemButton_OnMouseUp(self, button)
-- Only handle left-button drops
if button ~= "LeftButton" then return end
-- Don't allow interaction with other characters' items or in read-only mode
if self.otherChar or self.isReadOnly then
return
end
-- If the cursor is holding an item, drop/swap into this slot
if CursorHasItem and CursorHasItem() then
PickupContainerItem(self.bagID, self.slotID)
return
end
-- Otherwise, normal click behavior is handled by OnClick
end
-- OnDragStop handler (optional cleanup)
function Guda_ItemButton_OnDragStop(self)
-- Reset cursor to default to avoid lingering special cursors
if ResetCursor then
ResetCursor()
end
end
-- Stack split callback (called by StackSplitFrame)
local function ItemButton_SplitStack(self, split)
if self.bagID and self.slotID then
+6
View File
@@ -47,9 +47,15 @@
<OnClick>
Guda_ItemButton_OnClick(this, arg1)
</OnClick>
<OnMouseUp>
Guda_ItemButton_OnMouseUp(this, arg1)
</OnMouseUp>
<OnDragStart>
Guda_ItemButton_OnDragStart(this, arg1)
</OnDragStart>
<OnDragStop>
Guda_ItemButton_OnDragStop(this)
</OnDragStop>
<OnReceiveDrag>
Guda_ItemButton_OnReceiveDrag(this)
</OnReceiveDrag>