From 752e0106484480b564b3ca3f53c0fec27c23f18a Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Sun, 11 Jul 2010 01:51:20 -0400 Subject: [PATCH] In addition to pressing the Escape key, SearchBox focus can now be cleared by clicking on the WorldFrame. --- Frame.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Frame.lua b/Frame.lua index 101a8c9..f465b62 100644 --- a/Frame.lua +++ b/Frame.lua @@ -537,6 +537,37 @@ MainPanel.search_editbox = SearchBox SearchBox:SetText(_G.SEARCH) SearchBox:SetHistoryLines(10) +-- Allow removal of focus from the SearchBox by clicking on the WorldFrame. +do + local old_x, old_y, click_time + + WorldFrame:HookScript("OnMouseDown", + function(frame, ...) + if not SearchBox:HasFocus() then + return + end + old_x, old_y = GetCursorPosition() + click_time = GetTime() + end) + + WorldFrame:HookScript("OnMouseUp", + function(frame, ...) + if not SearchBox:HasFocus() then + return + end + local x, y = GetCursorPosition() + + if not old_x or not old_y or not x or not y or not click_time then + SearchBox:ClearFocus() + return + end + + if (math.abs(x - old_x) + math.abs(y - old_y)) <= 5 and GetTime() - click_time < .5 then + SearchBox:ClearFocus() + end + end) +end + -- Resets the SearchBox text and the state of all MainPanel.list_frame and recipe_list entries. function SearchBox:Reset() for index, recipe in pairs(private.recipe_list) do -- 1.7.9.5