Double-click Button on Android Touch Screen

The place to discuss anything and everything about running your LiveCode on Android

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
marra
Posts: 8
Joined: Mon Jul 23, 2018 3:32 pm

Double-click Button on Android Touch Screen

Post by marra » Thu Aug 09, 2018 4:38 pm

Hi,

I have a single button when pressed should add or subtract from a score.
When the button is clicked, it Add 1 to the total, if the user makes a mistake, the user must have the option to double-click or long-click the button to Subtract 1 from the Total.
I have the below code that works in the IDE (Windows), however on Android (touch Screen) the "mouseClick" is not registered.

I also looked at touchStart/End etc, with no success. How can I solve this?

on mouseUp
wait 20 ticks
if the mouseClick then
subtract 1 from fld "TotalScore"
else
add 1 to fld "TotalScore"
end if
end mouseUp


Regards
Marra

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2209
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Double-click Button on Android Touch Screen

Post by jmburnod » Thu Aug 09, 2018 6:41 pm

Hi Marra,
the user must have the option to double-click or long-click the button to Subtract 1 from the Total.
This should work:

Code: Select all

local sStartTime
on mousedown
   put the milliseconds into sStartTime
end mousedown

on mouseUp
   if  the milliseconds > (sStartTime + 200) then
      subtract 1 from fld "TotalScore"
      exit mouseUp
   else
      add 1 to fld "TotalScore"
   end if
end mouseUp
Best regards
Jean-Marc

marra
Posts: 8
Joined: Mon Jul 23, 2018 3:32 pm

Re: Double-click Button on Android Touch Screen

Post by marra » Thu Aug 09, 2018 6:55 pm

Hi Jean-Marc,

Works perfectly, thank you so much! :D

BR
Marra

Post Reply

Return to “Android Deployment”