Hi all,
I'm trying to do a widget that when a Key is pressed for at least 3 seconds, when it is released the widget will do certain action.
Everythings works on Simulator, but when I try on real target (Vivosmart HR) it does not work.
I look in the log in the Vivosmart HR and I do not see the message KEY PRESSED.
Instead doing onHold on the screen of Vivoactive HR it works both on Simulator and on Vivoactive HR
I report the code of the function KeyPressed and KeyReleased and onHold:
function onKeyPressed(evt)
{
keyPressedTime = System.getTimer();
Sys.println("KEY PRESSED\n");
return true;
}
function onKeyReleased(evt)
{
if (keyPressedTime > 0)
{
var delta = System.getTimer() - keyPressedTime;// ms since last press
keyPressedTime = 0;
if (delta > 3000)
{
Sys.println("LONG KEY RELEASED\n");// We have a hold
}
else
{
Sys.println("NORMAL KEY RELEASED\n");// We have a regular press
}
return true;
}
return false;
}
function onHold(evt)
{
Sys.println("HOLD\n");
return true;
}
Thanks for help me!!