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