Hi, I am tring to write a widget, it stops as soon as I press Up or Down (in the simulator) Has anybody a hint? I took it from the "Attention" sample of the SDK.
It's because you are on the initial view of the widget (which I like to call the "front page"). When you are looking at this view, you are on what's sometimes called the clock / widget loop, because you can scroll through the clock and all the widgets. Unfortunately you can't see the clock and other widgets in the sim, so it just exits your widget when you press UP or DOWN, instead of showing you another widget.
Imagine you are scrolling through widgets on your real watch. When you press up and down, it goes to the next widget or watchface, which means the current widget just closed. Your widget can't block or override that scrolling in the initial view.
What you have to do is handle onSelect() in a behaviour delegate, which is equivalent to pressing START on non-touchscreen watches, and tapping the screen on touchscreen watches. When the user does that, you push a second view and now you can handle whatever keys you want, to scroll through your widget's own pages. I like to think of this as "opening the widget", similar to opening an app. When the user is done, they press BACK and they're back in the widget loop.
In the built-in widgets, you'll notice that when you press START, the background colour changes from black to white to indicate you are in a new view. You might want to do this, unless of course your users prefer a black background all the time. (Which some do.)
TL;DR The idea is that the initial view of your widget shows a quick summary of interesting data. If they want to know more, they press START to dive in.
Another thing about widgets in the sim, is on watches they have a timeout and will return to the watchface after a but if there's no user interaction. This can be from about 20 seconds to a couple minutes depending on the device.