Page 1 of 1
mouseloc & multitouch
Posted: Wed Sep 16, 2015 11:07 pm
by rinzwind
in the handler for mouseDown or touchDown...
how do I get the x and y coordinate of all touches? The mouseloc only returns the first finger down, not the second. The target only returns the control below the finger... not the exact x and y.
Re: mouseloc & multitouch
Posted: Wed Sep 16, 2015 11:42 pm
by bn
Re: mouseloc & multitouch
Posted: Thu Sep 17, 2015 7:38 am
by rinzwind
nope there they use the target.. which is one of 9 buttons. Not exact x and y...
Re: mouseloc & multitouch
Posted: Thu Sep 17, 2015 8:49 am
by bn
there is a touchMove associated with touchStart.
I tried this on a device:
in the card script of a stack with one locked field that has its focusable unchecked (so that the keyboard does not pop up)
put this script
Code: Select all
local sTouchID1, sTouchID2
on touchStart tTID
if sTouchID1 = "" then
put tTID into sTouchID1
else
put tID into sTouchID2
end if
end touchStart
on touchMove tTID, x,y
if tTID = sTouchID1 then
put tTID && x,y into line 1 of field 1
else
put tTID && x,y into line 2 of field 1
end if
end touchMove
on touchEnd tTID
if tTID = sTouchID1 then
put "" into sTouchID1
end if
if tTID = sTouchID2 then
put "" into sTouchID2
end if
end touchEnd
this is just quick and dirty and you would have to refine it. But in my testing it gives me the location of both touches.
Kind regards
Bernd
Re: mouseloc & multitouch
Posted: Thu Sep 17, 2015 9:20 am
by rinzwind
aha so touchMove is also send when a touch starts (or isnt moved
). That helps. Still would be nice if mousePos would include
multitouch support or if x and y are supplied to touchStart/touchEnd.
Thanks!
Re: mouseloc & multitouch
Posted: Thu Sep 17, 2015 8:17 pm
by bn
this is fun,
try this with the same setUp as above: one locked and non-focusable field on a card
the card script:
Code: Select all
local sTouchArray
on touchStart tTID
put "" into sTouchArray[tTID]
end touchStart
on touchMove tTID, x,y
put x,y into sTouchArray[tTID]
upDateField
end touchMove
on touchEnd tTID
delete variable sTouchArray[tTID]
upDateField
end touchEnd
on touchRelease tTID
delete variable sTouchArray[tTID]
upDateField
end touchRelease
private command upDateField
put the keys of sTouchArray into tKeys
sort tKeys ascending numeric
put "" into tCollect
repeat for each line aKey in tKeys
put aKey & tab & sTouchArray[aKey] & return after tCollect
end repeat
delete last char of tCollect
put tCollect into field 1
end upDateField
it shows you all your current fingers. But as soon as you initiate a system gesture it will cancel your touches.
the use of "private command upDateField" instead of "on updateField" is because private command is a tad faster than the other form. -> dictionary private.
Of course you would have to test it on a device. Use both hands also.... Make the field a bit taller.
Kind regards
Bernd