From 83e8c24c46c88cfe54ea6fc3fea4823c33acec6d Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Thu, 13 Oct 2016 18:11:40 +0200 Subject: [PATCH] small bugfix, can now rightclick editboxes to clear the content --- gui/core.lua | 39 +++++++++++++++++++++++++++++---------- tabs/search/filter.lua | 1 + tabs/search/frame.lua | 4 ++++ tabs/search/results.lua | 4 ++-- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/gui/core.lua b/gui/core.lua index 5f400df..6575d56 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -307,6 +307,11 @@ function public.editbox(parent) end) editbox:SetScript('OnEnterPressed', function() (this.enter or nop)() end) editbox:SetScript('OnEditFocusGained', function() + if this.block_focus then + this.block_focus = false + this:ClearFocus() + return + end this.overlay:Hide() this:SetTextColor(color.text.enabled()) this.focused = true @@ -329,16 +334,22 @@ function public.editbox(parent) do local last_click = T('t', 0) editbox:SetScript('OnMouseDown', function() - local x, y = GetCursorPosition() - -- local offset = x - editbox:GetLeft()*editbox:GetEffectiveScale() TODO use a fontstring to measure getstringwidth for structural highlighting - -- or use an overlay with itemlinks - if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then - thread(function() editbox:HighlightText() end) - end - wipe(last_click) - last_click.t = GetTime() - last_click.x = x - last_click.y = y + if arg1 == 'RightButton' then + this:SetText'' + this:ClearFocus() + this.block_focus = true + else + local x, y = GetCursorPosition() + -- local offset = x - editbox:GetLeft()*editbox:GetEffectiveScale() TODO use a fontstring to measure getstringwidth for structural highlighting + -- or use an overlay with itemlinks + if GetTime() - last_click.t < .5 and x == last_click.x and y == last_click.y then + thread(function() editbox:HighlightText() end) + end + wipe(last_click) + last_click.t = GetTime() + last_click.x = x + last_click.y = y + end end) end function editbox:SetAlignment(alignment) @@ -546,4 +557,12 @@ function public.checkbox(parent) checkbox:GetCheckedTexture():SetTexCoord(.12, .88, .12, .88) checkbox:GetHighlightTexture'BLEND' return checkbox +end + +do + local editbox = CreateFrame'EditBox' + function public.clear_focus() + editbox:SetFocus() + editbox:ClearFocus() + end end \ No newline at end of file diff --git a/tabs/search/filter.lua b/tabs/search/filter.lua index 78f6d24..9bd05eb 100644 --- a/tabs/search/filter.lua +++ b/tabs/search/filter.lua @@ -87,6 +87,7 @@ function private.update_form() for key in temp-S('min_level', 'max_level') do if blizzard_query.exact then _M[key .. '_input']:EnableMouse(false) + _M[key .. '_input']:ClearFocus() else _M[key .. '_input']:EnableMouse(true) end diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 698a2e3..3b726fa 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -113,6 +113,7 @@ do editbox:SetPoint('RIGHT', start_button, 'LEFT', -4, 0) editbox:SetWidth(40) editbox:SetHeight(25) + editbox:SetAlignment'CENTER' editbox:SetNumeric(true) editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end) editbox.enter = execute @@ -124,6 +125,7 @@ do editbox:SetPoint('RIGHT', last_page_input, 'LEFT', -5.8, 0) editbox:SetWidth(40) editbox:SetHeight(25) + editbox:SetAlignment'CENTER' editbox:SetNumeric(true) editbox:SetScript('OnTabPressed', function() last_page_input:SetFocus() end) editbox.enter = execute @@ -289,6 +291,7 @@ do local editbox = gui.editbox(frame.filter) editbox:SetPoint('TOPLEFT', name_input, 'BOTTOMLEFT', 0, -FILTER_SPACING) editbox:SetWidth(125) + editbox:SetAlignment'CENTER' editbox:SetNumeric(true) editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then @@ -314,6 +317,7 @@ do local editbox = gui.editbox(frame.filter) editbox:SetPoint('TOPLEFT', min_level_input, 'TOPRIGHT', 10, 0) editbox:SetWidth(125) + editbox:SetAlignment'CENTER' editbox:SetNumeric(true) editbox:SetScript('OnTabPressed', function() if IsShiftKeyDown() then diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 30b03ce..8fea660 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -305,8 +305,6 @@ function public.execute(resume, real_time) new_search(filter_string, first_page, last_page) else current_search.filter_string = filter_string - current_search.first_page = first_page - current_search.last_page = last_page end new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';')) else @@ -316,6 +314,8 @@ function public.execute(resume, real_time) current_search.table:Reset() end end + current_search.first_page = first_page + current_search.last_page = last_page current_search.real_time = real_time_button:GetChecked() current_search.auto_buy_validator = auto_buy_validator end