fix: clickaway from bank search

This commit is contained in:
Salikh Gurgenidze
2025-11-22 00:48:14 +04:00
parent 4e81c122d0
commit c5b0622453
2 changed files with 50 additions and 0 deletions
+42
View File
@@ -11,6 +11,8 @@ local searchText = ""
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 bankBagParents = {} -- Parent frames per bank bag (same approach as BagFrame)
-- Global click catcher for clearing bank search focus
local bankClickCatcher = nil
-- OnLoad
function Guda_BankFrame_OnLoad(self)
@@ -21,6 +23,21 @@ function Guda_BankFrame_OnLoad(self)
searchBox:SetTextColor(0.5, 0.5, 0.5, 1)
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
-- OnShow
@@ -62,6 +79,10 @@ function Guda_BankFrame_OnHide(self)
end
end
end
-- Ensure the bank click catcher is hidden when the frame hides
if bankClickCatcher and bankClickCatcher.Hide then
bankClickCatcher:Hide()
end
end
-- Toggle visibility
@@ -574,6 +595,27 @@ function Guda_BankFrame_OnSearchChanged(self)
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
function Guda_BankFrame_Sort()
if isReadOnlyMode or currentViewChar then
+8
View File
@@ -286,8 +286,14 @@
this:SetText("")
this:SetTextColor(1, 1, 1, 1)
end
-- Show bank click catcher to detect clicks outside bank while typing
local cc = getglobal("Guda_BankClickCatcher")
if cc then cc:Show() end
</OnEditFocusGained>
<OnEditFocusLost>
-- Hide bank click catcher when focus is lost
local cc = getglobal("Guda_BankClickCatcher")
if cc then cc:Hide() end
if this:GetText() == "" then
this:SetText("Search bank...")
this:SetTextColor(0.5, 0.5, 0.5, 1)
@@ -302,6 +308,8 @@
this:SetTextColor(0.5, 0.5, 0.5, 1)
this:ClearFocus()
Guda_BankFrame_OnSearchChanged(this)
local cc = getglobal("Guda_BankClickCatcher")
if cc then cc:Hide() end
</OnEscapePressed>
</Scripts>
</EditBox>