From d24aa67cd9d158a31d855a3d009c6e0ce0667a60 Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Sat, 10 Jul 2010 02:18:28 -0400 Subject: [PATCH] Improved search editbox functionality - focus is only lost when escape is pressed, not when every letter has been deleted - in that case, the text is reset and highlighted for type-over. --- Frame.lua | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Frame.lua b/Frame.lua index 00be1d7..467193e 100644 --- a/Frame.lua +++ b/Frame.lua @@ -537,15 +537,16 @@ SearchBox:SetHistoryLines(10) -- Resets the SearchBox text and the state of all MainPanel.list_frame and recipe_list entries. function SearchBox:Reset() - local recipe_list = private.recipe_list - - for index, recipe in pairs(recipe_list) do + for index, recipe in pairs(private.recipe_list) do recipe:RemoveState("RELEVANT") end self.prev_search = nil self:SetText(_G.SEARCH) - self:ClearFocus() + + if self:HasFocus() then + self:HighlightText() + end MainPanel.list_frame:Update(nil, false) end @@ -568,31 +569,25 @@ SearchBox:SetScript("OnEnterPressed", self:Reset() return end + self:HighlightText() if searchtext == _G.SEARCH then - self:HighlightText() return end self.prev_search = searchtext - self:HighlightText() self:AddHistoryLine(searchtext) SearchRecipes(searchtext) MainPanel.list_frame:Update(nil, false) end) -SearchBox:SetScript("OnEditFocusGained", - function(self) - if self:GetText() == _G.SEARCH then - self:HighlightText() - end - end) +SearchBox:SetScript("OnEditFocusGained", SearchBox.HighlightText) SearchBox:SetScript("OnEditFocusLost", function(self) local text = self:GetText() - if text == "" then + if text == "" or text == _G.SEARCH then self:Reset() return end -- 1.7.9.5