fix: clickaway from bank search
This commit is contained in:
@@ -11,6 +11,8 @@ local searchText = ""
|
|||||||
local isReadOnlyMode = false -- Track if viewing saved bank (read-only) or live bank (interactive)
|
local isReadOnlyMode = false -- Track if viewing saved bank (read-only) or live bank (interactive)
|
||||||
local hiddenBankBags = {} -- Track which bank bags are hidden (bagID -> true/false)
|
local hiddenBankBags = {} -- Track which bank bags are hidden (bagID -> true/false)
|
||||||
local bankBagParents = {} -- Parent frames per bank bag (same approach as BagFrame)
|
local bankBagParents = {} -- Parent frames per bank bag (same approach as BagFrame)
|
||||||
|
-- Global click catcher for clearing bank search focus
|
||||||
|
local bankClickCatcher = nil
|
||||||
|
|
||||||
-- OnLoad
|
-- OnLoad
|
||||||
function Guda_BankFrame_OnLoad(self)
|
function Guda_BankFrame_OnLoad(self)
|
||||||
@@ -21,6 +23,21 @@ function Guda_BankFrame_OnLoad(self)
|
|||||||
searchBox:SetTextColor(0.5, 0.5, 0.5, 1)
|
searchBox:SetTextColor(0.5, 0.5, 0.5, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Create invisible full-screen frame to catch clicks outside the bank frame while typing in search
|
||||||
|
if not bankClickCatcher then
|
||||||
|
bankClickCatcher = CreateFrame("Frame", "Guda_BankClickCatcher", UIParent)
|
||||||
|
bankClickCatcher:SetFrameStrata("BACKGROUND")
|
||||||
|
bankClickCatcher:SetAllPoints(UIParent)
|
||||||
|
bankClickCatcher:EnableMouse(true)
|
||||||
|
bankClickCatcher:Hide()
|
||||||
|
|
||||||
|
bankClickCatcher:SetScript("OnMouseDown", function()
|
||||||
|
if Guda_BankFrame_ClearSearch then
|
||||||
|
Guda_BankFrame_ClearSearch()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- OnShow
|
-- OnShow
|
||||||
@@ -62,6 +79,10 @@ function Guda_BankFrame_OnHide(self)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Ensure the bank click catcher is hidden when the frame hides
|
||||||
|
if bankClickCatcher and bankClickCatcher.Hide then
|
||||||
|
bankClickCatcher:Hide()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Toggle visibility
|
-- Toggle visibility
|
||||||
@@ -574,6 +595,27 @@ function Guda_BankFrame_OnSearchChanged(self)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Clear bank search and restore placeholder
|
||||||
|
function Guda_BankFrame_ClearSearch()
|
||||||
|
local searchBox = getglobal("Guda_BankFrame_SearchBar_SearchBox")
|
||||||
|
if searchBox then
|
||||||
|
searchBox:SetText("Search bank...")
|
||||||
|
searchBox:SetTextColor(0.5, 0.5, 0.5, 1)
|
||||||
|
if searchBox.ClearFocus then searchBox:ClearFocus() end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Reset search state
|
||||||
|
searchText = ""
|
||||||
|
|
||||||
|
-- Update display
|
||||||
|
BankFrame:Update()
|
||||||
|
|
||||||
|
-- Hide click catcher if present
|
||||||
|
if bankClickCatcher and bankClickCatcher.Hide then
|
||||||
|
bankClickCatcher:Hide()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Sort button handler with auto-repeat and smart pass calculation
|
-- Sort button handler with auto-repeat and smart pass calculation
|
||||||
function Guda_BankFrame_Sort()
|
function Guda_BankFrame_Sort()
|
||||||
if isReadOnlyMode or currentViewChar then
|
if isReadOnlyMode or currentViewChar then
|
||||||
|
|||||||
@@ -286,8 +286,14 @@
|
|||||||
this:SetText("")
|
this:SetText("")
|
||||||
this:SetTextColor(1, 1, 1, 1)
|
this:SetTextColor(1, 1, 1, 1)
|
||||||
end
|
end
|
||||||
|
-- Show bank click catcher to detect clicks outside bank while typing
|
||||||
|
local cc = getglobal("Guda_BankClickCatcher")
|
||||||
|
if cc then cc:Show() end
|
||||||
</OnEditFocusGained>
|
</OnEditFocusGained>
|
||||||
<OnEditFocusLost>
|
<OnEditFocusLost>
|
||||||
|
-- Hide bank click catcher when focus is lost
|
||||||
|
local cc = getglobal("Guda_BankClickCatcher")
|
||||||
|
if cc then cc:Hide() end
|
||||||
if this:GetText() == "" then
|
if this:GetText() == "" then
|
||||||
this:SetText("Search bank...")
|
this:SetText("Search bank...")
|
||||||
this:SetTextColor(0.5, 0.5, 0.5, 1)
|
this:SetTextColor(0.5, 0.5, 0.5, 1)
|
||||||
@@ -302,6 +308,8 @@
|
|||||||
this:SetTextColor(0.5, 0.5, 0.5, 1)
|
this:SetTextColor(0.5, 0.5, 0.5, 1)
|
||||||
this:ClearFocus()
|
this:ClearFocus()
|
||||||
Guda_BankFrame_OnSearchChanged(this)
|
Guda_BankFrame_OnSearchChanged(this)
|
||||||
|
local cc = getglobal("Guda_BankClickCatcher")
|
||||||
|
if cc then cc:Hide() end
|
||||||
</OnEscapePressed>
|
</OnEscapePressed>
|
||||||
</Scripts>
|
</Scripts>
|
||||||
</EditBox>
|
</EditBox>
|
||||||
|
|||||||
Reference in New Issue
Block a user