From 425e48e9279b17d48df2613ca8ef89a166388f7d Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Fri, 16 Sep 2016 12:47:57 +0200 Subject: [PATCH] completion bugfix --- Postal.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Postal.lua b/Postal.lua index 9e8b6ce..66fd9bb 100644 --- a/Postal.lua +++ b/Postal.lua @@ -169,6 +169,7 @@ function self:ADDON_LOADED() SendMailNameEditBox:SetScript('OnEnterPressed', function() if AutoCompleteBox:IsVisible() then AutoCompleteBox:Hide() + this:HighlightText(0, 0) else PostalSubjectEditBox:SetFocus() end @@ -180,12 +181,16 @@ function self:ADDON_LOADED() this:ClearFocus() end end) + function SendMailNameEditBox.focusLoss() + AutoCompleteBox:Hide() + end for _, editBox in { SendMailNameEditBox, SendMailSubjectEditBox } do editBox:SetScript('OnEditFocusGained', function() this:HighlightText() end) editBox:SetScript('OnEditFocusLost', function() + (this.focusLoss or function() end)() this:HighlightText(0, 0) end) do @@ -734,6 +739,7 @@ do index = i complete() AutoCompleteBox:Hide() + SendMailNameEditBox:HighlightText(0, 0) end function self:GetMatches() @@ -741,6 +747,7 @@ do inputLength = strlen(input) table.setn(matches, 0) + index = nil local name for i = 1, GetNumFriends() do @@ -756,10 +763,6 @@ do end end - if matches[1] then - index = 1 - end - table.setn(matches, min(getn(matches), AUTOCOMPLETE_MAX_BUTTONS)) if getn(matches) > 0 then for i = 1, AUTOCOMPLETE_MAX_BUTTONS do @@ -775,10 +778,10 @@ do AutoCompleteBox:SetHeight(getn(matches) * AutoCompleteButton1:GetHeight() + 35) AutoCompleteBox:SetWidth(120) AutoCompleteBox:Show() + index = 1 + complete() else AutoCompleteBox:Hide() end - index = 1 - complete(index) end end \ No newline at end of file