As an example, if you use a number picker for NUMBER_PICKER_HEIGHT with an value of 4.0 (meters), the simulator will provide an initial value of 400.00 cm (or 157.48 in depending on the height unit setting), and will pass that value to the onNumberPicked() callback. On a physical device, the initial value displayed is 400 cm (or 13 ft 1 in). When you advance to the next number field by pressing enter or swiping, the value will suddenly change to 25.4 cm (or 8 ft 4 in).
using Toybox.Application as App;
using Toybox.Graphics as Gfx;
using Toybox.WatchUi as Ui;
class MyViewDelegate extends Ui.InputDelegate
{
function onKey(evt) {
var key = evt.getKey();
if (key == Ui.KEY_ESC) {
Ui.popView(Ui.SLIDE_IMMEDIATE);
}
else if (key == Ui.KEY_MENU) {
var picker = new Ui.NumberPicker(Ui.NUMBER_PICKER_HEIGHT, 4.0);
Ui.pushView(picker, new Ui.NumberPickerDelegate(), Ui.SLIDE_IMMEDIATE);
}
else {
return false;
}
return true;
}
}
class MyView extends Ui.View
{
function onUpdate(dc) {
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.clear();
var cx = dc.getWidth() / 2;
var cy = dc.getHeight() / 2;
dc.drawText(cx, cy, Gfx.FONT_LARGE, "Press Menu", Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
}
}
class MyApp extends App.AppBase
{
function getInitialView() {
var view = new MyView();
var delegate = new MyViewDelegate();
return [ view, delegate ];
}
}