From bbbcdffd3b8920edfb41bb7d207645c164d3e063 Mon Sep 17 00:00:00 2001 From: poire-z Date: Sun, 1 Jan 2023 16:11:10 +0100 Subject: [PATCH] ButtonTable: reset MovableContainer state on button tap Prevent any later hold_release event from being handled by MovableContainer as a moving touch+hold_release. This issue was noticable when closing DictQuickLookup with long-press on close, resulting in the movable highlight actions ButtonTable moving to where the long-press happened. --- frontend/ui/widget/buttontable.lua | 7 ++++++- frontend/ui/widget/container/movablecontainer.lua | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/ui/widget/buttontable.lua b/frontend/ui/widget/buttontable.lua index a48a5b8dc..7bc9a09cf 100644 --- a/frontend/ui/widget/buttontable.lua +++ b/frontend/ui/widget/buttontable.lua @@ -55,7 +55,12 @@ function ButtonTable:init() icon_height = btn_entry.icon_height, align = btn_entry.align, enabled = btn_entry.enabled, - callback = btn_entry.callback, + callback = function() + if self.show_parent and self.show_parent.movable then + self.show_parent.movable:resetEventState() + end + btn_entry.callback() + end, hold_callback = btn_entry.hold_callback, allow_hold_when_disabled = btn_entry.allow_hold_when_disabled, vsync = btn_entry.vsync, diff --git a/frontend/ui/widget/container/movablecontainer.lua b/frontend/ui/widget/container/movablecontainer.lua index 375066fdd..c90f47f55 100644 --- a/frontend/ui/widget/container/movablecontainer.lua +++ b/frontend/ui/widget/container/movablecontainer.lua @@ -342,4 +342,11 @@ function MovableContainer:onMovablePanRelease(_, ges) return false end +function MovableContainer:resetEventState() + -- Cancel some internal moving-or-about-to-move state. + -- Can be called explicitely to prevent bad widget interactions. + self._touch_pre_pan_was_inside = false + self._moving = false +end + return MovableContainer