Button: don't handle long-press when not enabled

It was only not handled when hold_callback. Do that
also when hold_input/hold_input_func.
Also fix the handling of HoldRelease (as the Hold may
change the state of 'enabled', so we can't rely
on it to guess the Hold is being handled by Button).
Menu: prevent long-press on "No choice available",
as there's then no page to navigate to.
reviewable/pr7310/r1 v2021.02
poire-z 3 years ago
parent e44c170f59
commit 6132e8c904

@ -401,12 +401,21 @@ function Button:refresh()
end
function Button:onHoldSelectButton()
if self.hold_callback and (self.enabled or self.allow_hold_when_disabled) then
self.hold_callback()
elseif self.hold_input then
self:onInput(self.hold_input, true)
elseif type(self.hold_input_func) == "function" then
self:onInput(self.hold_input_func(), true)
-- If we're going to process this hold, we must make
-- sure to also handle its hold_release below, so it's
-- not propagated up to a MovableContainer
self._hold_handled = nil
if self.enabled or self.allow_hold_when_disabled then
if self.hold_callback then
self.hold_callback()
self._hold_handled = true
elseif self.hold_input then
self:onInput(self.hold_input, true)
self._hold_handled = true
elseif type(self.hold_input_func) == "function" then
self:onInput(self.hold_input_func(), true)
self._hold_handled = true
end
end
if self.readonly ~= true then
return true
@ -414,12 +423,8 @@ function Button:onHoldSelectButton()
end
function Button:onHoldReleaseSelectButton()
-- Safe-guard for when used inside a MovableContainer,
-- which would handle HoldRelease and process it like
-- a Hold if we wouldn't return true here
if self.hold_callback and (self.enabled or self.allow_hold_when_disabled) then
return true
elseif self.hold_input or type(self.hold_input_func) == "function" then
if self._hold_handled then
self._hold_handled = nil
return true
end
return false

@ -1024,6 +1024,7 @@ function Menu:updatePageInfo(select_number)
-- update page information
if self.page_num > 1 then
self.page_info_text:setText(FFIUtil.template(_("Page %1 of %2"), self.page, self.page_num))
self.page_info_text.enabled = true
else
self.page_info_text:setText("");
end
@ -1040,6 +1041,7 @@ function Menu:updatePageInfo(select_number)
self.page_return_arrow:enableDisable(#self.paths > 0)
else
self.page_info_text:setText(_("No choices available"))
self.page_info_text.enabled = false
end
end

Loading…
Cancel
Save