MartinCouture
Technical User
I would like a button to do
press -> do A
Press longer than 1 second -> do B
All with the same button.
The problem is that on(press) doesn't care if it's 1 second or an hour. My solution was to try with:
on (release) {
if (!long_press) {
-== DO A STUFF ==-
}
}
on (press) {
mydate = new Date();
time_in_sec = int(mydate.getTime()/1000);
start_press = time_in_sec;
x = 0;
while (x<2) {
mydate = new Date();
time_in_sec = int(mydate.getTime()/1000);
x = time_in_sec-start_press;
if (x>1) {
long_press = true;
-== DO B STUFF ==-
}
}
}
Any hints out there. It's for a panel in the airplane and lots of the buttons do different actions depending if it's a short press or a long press.
Thanks
-----------------
[flush]
press -> do A
Press longer than 1 second -> do B
All with the same button.
The problem is that on(press) doesn't care if it's 1 second or an hour. My solution was to try with:
on (release) {
if (!long_press) {
-== DO A STUFF ==-
}
}
on (press) {
mydate = new Date();
time_in_sec = int(mydate.getTime()/1000);
start_press = time_in_sec;
x = 0;
while (x<2) {
mydate = new Date();
time_in_sec = int(mydate.getTime()/1000);
x = time_in_sec-start_press;
if (x>1) {
long_press = true;
-== DO B STUFF ==-
}
}
}
Any hints out there. It's for a panel in the airplane and lots of the buttons do different actions depending if it's a short press or a long press.
Thanks
-----------------
[flush]