2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00

SortWidget: Preserve the cancel's button highlight when changing its icon

setIcon recreates the frame without preserving the current frame's
invert status (which is arguably a bug, but button is so ubuquitous that
I dare not touch that behavior...).

So, instead, rely on the rarely used preselect flag to preserve it.
This commit is contained in:
NiLuJe 2024-08-16 05:05:38 +02:00
parent c21ad4edcc
commit cfd42254ac

View File

@ -438,11 +438,14 @@ function SortWidget:_populateItems()
chevron_first, chevron_last = chevron_last, chevron_first chevron_first, chevron_last = chevron_last, chevron_first
end end
if self.marked > 0 then if self.marked > 0 then
-- setIcon will recreate the frame, but we want to preserve the focus inversion
self.footer_cancel.preselect = self.footer_cancel.frame.invert
self.footer_cancel:setIcon("cancel", self.footer_button_width) self.footer_cancel:setIcon("cancel", self.footer_button_width)
self.footer_cancel.callback = function() self:onCancel() end self.footer_cancel.callback = function() self:onCancel() end
self.footer_first_up:setIcon("move.up", self.footer_button_width) self.footer_first_up:setIcon("move.up", self.footer_button_width)
self.footer_last_down:setIcon("move.down", self.footer_button_width) self.footer_last_down:setIcon("move.down", self.footer_button_width)
else else
self.footer_cancel.preselect = self.footer_cancel.frame.invert
self.footer_cancel:setIcon("exit", self.footer_button_width) self.footer_cancel:setIcon("exit", self.footer_button_width)
self.footer_cancel.callback = function() self:onClose() end self.footer_cancel.callback = function() self:onClose() end
self.footer_first_up:setIcon(chevron_first, self.footer_button_width) self.footer_first_up:setIcon(chevron_first, self.footer_button_width)