some autocomplete improvements
This commit is contained in:
@@ -79,7 +79,7 @@ function Aux.buy.SearchButton_onclick()
|
||||
current_page = page
|
||||
end,
|
||||
on_start_page = function(page, total_pages)
|
||||
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
|
||||
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages > 0 and ' out of ' .. total_pages or '') .. ' ...')
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
local auction_item = Aux.info.auction_item(i)
|
||||
|
||||
@@ -91,9 +91,9 @@
|
||||
</Layer>
|
||||
</Layers>
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
<OnShow>
|
||||
this.completor = Aux.completion.completor(this)
|
||||
</OnLoad>
|
||||
</OnShow>
|
||||
<OnTextChanged>
|
||||
this.completor.suggest()
|
||||
</OnTextChanged>
|
||||
@@ -105,9 +105,7 @@
|
||||
end
|
||||
</OnTabPressed>
|
||||
<OnEnterPressed>
|
||||
if this.completor.open() then
|
||||
this.completor.close()
|
||||
end
|
||||
this.completor.close()
|
||||
this:ClearFocus()
|
||||
Aux.buy.SearchButton_onclick()
|
||||
</OnEnterPressed>
|
||||
|
||||
+14
-12
@@ -104,21 +104,21 @@ function Aux.completion.completor(edit_box)
|
||||
end
|
||||
end
|
||||
|
||||
function self:close()
|
||||
function self.close()
|
||||
CloseDropDownMenus(1)
|
||||
end
|
||||
|
||||
function self:set_quietly(text)
|
||||
function self.set_quietly(text)
|
||||
quietly_set_text = text
|
||||
edit_box:SetText(text)
|
||||
end
|
||||
|
||||
function self:completed()
|
||||
return index ~= 0
|
||||
function self.open()
|
||||
local _, owner = DropDownList1:GetPoint()
|
||||
return DropDownList1:IsVisible() and owner == edit_box
|
||||
end
|
||||
|
||||
function self:suggest()
|
||||
|
||||
function self.suggest()
|
||||
local new_input = edit_box:GetText()
|
||||
if new_input == quietly_set_text then
|
||||
quietly_set_text = nil
|
||||
@@ -140,26 +140,28 @@ function Aux.completion.completor(edit_box)
|
||||
update_dropdown()
|
||||
end
|
||||
|
||||
function self:next()
|
||||
function self.next()
|
||||
update_dropdown()
|
||||
if getn(suggestions) > 0 then
|
||||
index = index > 0 and math.mod(index + 1, getn(suggestions) + 1) or 1
|
||||
self:update_highlighting()
|
||||
update_highlighting()
|
||||
if index == 0 then
|
||||
self:set_quietly(input)
|
||||
self.set_quietly(input)
|
||||
else
|
||||
self:set_quietly(suggestions[index])
|
||||
self.set_quietly(suggestions[index])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function self.previous()
|
||||
update_dropdown()
|
||||
if getn(suggestions) > 0 then
|
||||
index = index > 0 and index - 1 or getn(suggestions)
|
||||
update_highlighting()
|
||||
if index == 0 then
|
||||
self:set_quietly(input)
|
||||
self.set_quietly(input)
|
||||
else
|
||||
self:set_quietly(suggestions[index])
|
||||
self.set_quietly(suggestions[index])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ end)()
|
||||
|
||||
local state, abort, new_job
|
||||
|
||||
local scan, scan_auctions, scan_auctions_helper, submit_query, wait_for_callback, wait_for_results, abort
|
||||
local scan, scan_auctions, scan_auctions_helper, submit_query, wait_for_callback, wait_for_results, wait_for_complete_results, abort
|
||||
|
||||
function Aux.scan.start(job)
|
||||
Aux.control.on_next_update(function()
|
||||
@@ -125,7 +125,7 @@ end
|
||||
|
||||
function submit_query(k)
|
||||
if state.page then
|
||||
wait_for_callback(state.job.on_start_page, {state.page, state.total_pages}, function()
|
||||
wait_for_callback(state.job.on_start_page, {state.page, state.total_pages or 0}, function()
|
||||
controller().wait(CanSendAuctionQuery, function()
|
||||
if state.job.on_submit_query then
|
||||
state.job.on_submit_query()
|
||||
|
||||
@@ -342,7 +342,7 @@ function refresh_entries()
|
||||
},
|
||||
page = 0,
|
||||
on_start_page = function(page, total_pages)
|
||||
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
|
||||
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages > 0 and ' out of ' .. total_pages or '') .. ' ...')
|
||||
end,
|
||||
on_read_auction = function(i)
|
||||
local auction_item = Aux.info.auction_item(i)
|
||||
|
||||
@@ -240,7 +240,7 @@ function Aux.util.group_by(tables, keys)
|
||||
local groups = {}
|
||||
Aux.util.map(tables, function(table)
|
||||
for _, group in ipairs(groups) do
|
||||
if Aux.util.all(keys, function(key) table[key] == group[1][key] end) then
|
||||
if Aux.util.all(keys, function(key) return table[key] == group[1][key] end) then
|
||||
tinsert(group, table)
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user