I would like to create note on my Fenix3 / How to get key event

Former Member
Former Member
I've would like to put some notes on my Fenix3, But there's no any note app and it didn't support my language.

So I decide to create widget to show my note I chose to make note as picture.

I've try it with basic widget, add picture and edited a little line of code so I can make I show the note.
But only one page.
I would like to get key event to move to another page of note.

such as
//When Key is press
...{
screen1 = screen1+1;
if(screen1>4){screen1=0;}
if(screen1==0)
{
setLayout(Rez.Layouts.MainLayout(dc));
}
if(screen1==1)
{
setLayout(Rez.Layouts.MainLayout1(dc));
}
if(screen1==2)
{
setLayout(Rez.Layouts.MainLayout2(dc));
}
if(screen1==3)
{
setLayout(Rez.Layouts.MainLayout3(dc));
}
if(screen1==4)
{
setLayout(Rez.Layouts.MainLayout4(dc));
}
}...




Here's my code.
using Toybox.WatchUi as Ui;
var screen1;
class testtView extends Ui.View {

//! Load your resources here
function onLayout(dc) {
screen1=1;
setLayout(Rez.Layouts.MainLayout2(dc));
}

//! Restore the state of the app and prepare the view to be shown
function onShow() {
}

//! Update the view
function onUpdate(dc) {
// Call the parent onUpdate function to redraw the layout
View.onUpdate(dc);
}

//! Called when this View is removed from the screen. Save the
//! state of your app here.
function onHide() {
}

}


And more question
Can I load my widget to my Fenix3 without put it to store. If I can how to do that?

Thanks
  • Here u find the answer on your last quistion, unfortunately I can't help u with the first quistion. I sure someone els will help u with the rest ;)

    https://forums.garmin.com/showthread.php?231358-Connect-IQ-Questions

    read #2
  • Former Member
    Former Member over 10 years ago
    Thank, I've tried load app to watch. It's OK

    still find how to get push button event

    found that in some thread, they create new class.

    class AlertPickerDelegate extends Ui.InputDelegate {
    ...
    function initialize(hilo, persist, view)
    {...}
    function onKey(evt)
    {...}
    function onTap(evt)
    {...}
    function increment(inc)
    {...}
    }


    So I tried add class.
    class testtViewDelegate extends Ui.InputDelegate {

    function onKey(evt)
    {
    screen1 = screen1+1;
    if(screen1>4){screen1=0;}
    if(screen1==0)
    {
    setLayout(Rez.Layouts.MainLayout(dc));
    }
    if(screen1==1)
    {
    setLayout(Rez.Layouts.MainLayout1(dc));
    }
    if(screen1==2)
    {
    setLayout(Rez.Layouts.MainLayout2(dc));
    }
    if(screen1==3)
    {
    setLayout(Rez.Layouts.MainLayout3(dc));
    }
    if(screen1==4)
    {
    setLayout(Rez.Layouts.MainLayout4(dc));
    }
    }

    }


    But it didn't work. Is there anything I need to do more to make it know about the button event?


    A little more question
    In simulator, can I press watch button?
  • You need to tell the framework that you have an input delegate. The array returned from getInitialView() should have a second value that is the input delegate.

    All of this is covered in the example programs and in the users guide. You should take a break from coding and do some reading.
  • Former Member
    Former Member over 10 years ago
    Thanks, I've just found that example are in sdk folder. I tried to find them in dev website.
    Now It's Done. Thanks.