From 8f341cebb0bc312fb5996f055af2a6d8b718e0a8 Mon Sep 17 00:00:00 2001 From: "Squishy (C6H12O6+NaCl+H2O)" <106439598+SweetSea-ButImNotSweet@users.noreply.github.com> Date: Sun, 30 Jul 2023 13:46:05 +0700 Subject: [PATCH] fix touch bug --- parts/scenes/dict.lua | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/parts/scenes/dict.lua b/parts/scenes/dict.lua index 58f2fbe01..0e320f16d 100644 --- a/parts/scenes/dict.lua +++ b/parts/scenes/dict.lua @@ -22,7 +22,7 @@ local showingHelp=false -- Help is triggered or not local zoomWait=0 -- The last time zoom is triggered local oldScrollPos=0 -local lastMousePos +local lastMousePos, lastTouchPos local typeColor={ help=COLOR.Y, @@ -293,14 +293,30 @@ function scene.gamepadDown(key) end end -function scene.mouseDown() - lastMousePos=love.mouse.getPosition() +function scene.mouseDown(mx,my) + lastMousePos={mx,my} +end +function scene.touchDown(mx,my) + lastTouchPos={mx,my} end -- Check if left mouse key is released -function scene.mouseUp() +function scene.mouseUp(mx,my) + if WIDGET.isFocus(listBox) then + if oldScrollPos~=listBox.scrollPos and {mx,my}~=lastMousePos then + oldScrollPos=listBox.scrollPos + listBox.selected=lastSelected + listBox.scrollPos=oldScrollPos + else + lastSelected=listBox.selected + scene.widgetList.copy.hide=false + _updateInfoBox() + end + end +end +function scene.touchUp(mx,my) if WIDGET.isFocus(listBox) then - if oldScrollPos~=listBox.scrollPos and love.mouse.getPosition()~=lastMousePos then + if oldScrollPos~=listBox.scrollPos and {mx,my}~=lastTouchPos then oldScrollPos=listBox.scrollPos listBox.selected=lastSelected listBox.scrollPos=oldScrollPos