CheckButton: fix hold when in a movable container (#7948)

pull/7958/head
poire-z 3 years ago committed by GitHub
parent f411035d7d
commit ca91df1f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -91,6 +91,14 @@ function CheckButton:initCheckButton(checked)
range = self.dimen, range = self.dimen,
}, },
doc = "Hold Button", doc = "Hold Button",
},
-- Safe-guard for when used inside a MovableContainer
HoldReleaseCheckButton = {
GestureRange:new{
ges = "hold_release",
range = self.dimen,
},
doc = "Hold Release Button",
} }
} }
end end
@ -138,16 +146,33 @@ function CheckButton:onTapCheckButton()
end end
function CheckButton:onHoldCheckButton() function CheckButton:onHoldCheckButton()
if self.enabled and self.hold_callback 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) self._hold_handled = nil
elseif type(self.hold_input_func) == "function" then if self.enabled then
self:onInput(self.hold_input_func()) 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
return true return true
end end
function CheckButton:onHoldReleaseCheckButton()
if self._hold_handled then
self._hold_handled = nil
return true
end
return false
end
function CheckButton:check() function CheckButton:check()
self:initCheckButton(true) self:initCheckButton(true)
UIManager:setDirty(self.parent, function() UIManager:setDirty(self.parent, function()

Loading…
Cancel
Save