Hi
i'm beginner to use MonkeyC.
I have change Input example (in the source InputView.mc) adding :
if (status_string == "KEY_START PRESSED") {
but not works.
Where is my mistake ?
i want that pressing KEY_START start activity.
thanks
Hi
i'm beginner to use MonkeyC.
I have change Input example (in the source InputView.mc) adding :
if (status_string == "KEY_START PRESSED") {
but not works.
Where is my mistake ?
i want that pressing KEY_START start activity.
thanks
If doesn't work to test strings
use switch statment instead
https://developer.garmin.com/connect-iq/programmers-guide/monkey-c/
Thanks much Shent.
Now works fine!
To compare strings, you do it differently than just ==.
if(status_string.equals("KEY_START")) {
But I'm wondering what you're trying to do, as an easier way to look for that is in the delegate and just do a compare based on evt.getKey(). in the input sample, getKeyString() is just taking the key and returning a string, and it looks to be the string you're comparing to.
thanks Jim.
Works also fine to compare string.
I want start timer (00:00:00) of time of activity (i dont know if i can use also other way for to do this) and if i press start key start timer.
I have also InputDelegate.mc in the project..then i can use also getKeyString() ?
Excuse me.. i'm beginner..
thanks
You really don't need it. Here's stripped down part of one of my delegates:
class HikeDelegate extends Ui.BehaviorDelegate { function initialize() { BehaviorDelegate.initialize(); } function onKey(evt) { var lastKey=evt.getKey(); if(lastKey==Ui.KEY_ENTER || lastKey==Ui.KEY_START) { //do your thing here return true; } return false; } }
There's no need to take the key and make it into a string. You can just do what you need based on the key itself.
I'm trying to remember a sample that might sown this better. The input sample is mainly to show what's happening with messages on the screen, and that's why things are converted into strings.