Skip to content

Commit

Permalink
fix touch bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SweetSea-ButImNotSweet committed Jul 30, 2023
1 parent 28b4dbc commit 8f341ce
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions parts/scenes/dict.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f341ce

Please sign in to comment.