From 946336c7cc6a734ef5e7e1a5b4946c38cb633cc9 Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Tue, 18 Nov 2025 23:45:08 +0400 Subject: [PATCH] fix: split items --- UI/ItemButton.lua | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index a6983b8..aebbff3 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -339,6 +339,13 @@ function Guda_ItemButton_OnReceiveDrag(self) PickupContainerItem(self.bagID, self.slotID) end +-- Stack split callback (called by StackSplitFrame) +local function ItemButton_SplitStack(self, split) + if self.bagID and self.slotID then + SplitContainerItem(self.bagID, self.slotID, split) + end +end + -- OnClick handler function Guda_ItemButton_OnClick(self, button) -- Don't allow interaction with other characters' items or in read-only mode @@ -346,11 +353,24 @@ function Guda_ItemButton_OnClick(self, button) return end + -- Set the split callback + self.SplitStack = ItemButton_SplitStack + -- Handle modified clicks first if IsShiftKeyDown() then - -- Shift+Click: Link in chat - if self.hasItem and self.itemData and self.itemData.link then - if ChatFrameEditBox:IsVisible() then + if button == "LeftButton" and self.hasItem then + -- Shift+Left Click on stackable item: Show split stack dialog + if self.itemData and self.itemData.count and self.itemData.count > 1 then + -- Get the actual stack count from the container + local _, count = GetContainerItemInfo(self.bagID, self.slotID) + if count and count > 1 then + -- Open the stack split frame (positioned to the left) + OpenStackSplitFrame(count, self, "BOTTOMRIGHT", "TOPRIGHT") + return + end + end + -- If not stackable or only 1 item, link to chat + if self.itemData and self.itemData.link and ChatFrameEditBox:IsVisible() then ChatFrameEditBox:Insert(self.itemData.link) end end