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

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

Loading…
Cancel
Save