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,
},
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
@ -138,16 +146,33 @@ function CheckButton:onTapCheckButton()
end
function CheckButton:onHoldCheckButton()
if self.enabled and self.hold_callback then
self.hold_callback()
elseif self.hold_input then
self:onInput(self.hold_input)
elseif type(self.hold_input_func) == "function" then
self:onInput(self.hold_input_func())
-- 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 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
return true
end
function CheckButton:onHoldReleaseCheckButton()
if self._hold_handled then
self._hold_handled = nil
return true
end
return false
end
function CheckButton:check()
self:initCheckButton(true)
UIManager:setDirty(self.parent, function()

Loading…
Cancel
Save