[CIQBUG] Number picker initial value not limited to bounds

The number picker documentation indicates that it is supposed to modify the initial value to be within the minimum and maximum values for each mode. In my testing on physical devices (fr920xt w/ 3.30, vivoactive w/ 2.80), the initial value is not properly limited to the accepted range. When you attempt to modify the value, the limits are enforced. On the simulator, no limit on the value is enforced at all.

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 ];
}
}
  • Thanks again for the detailed report--I'll get this investigated.
  • I was able to reproduce this. Looks like it's limiting lengths to 254 cm which suggests a type limitation behind the scenes (I haven't checked the source to verify).

    I'm going to go through all of the number picker modes to see what else I can root out. I've already found an inconsistency where the sim will accept pretty much any initialization value for NUMBER_PICKER_TIME (even strings!), but the app will crash if anything but a Duration is provided.
  • Just an update to this. I've been slowly working my way through the entire number picker API, and have identified a few inconsistencies and several undocumented items (for example, the birth year picker, though a simple number picker in the code, limits the selection to years between 1900 and the current year). Part of my responsibility is to go through the API and identify test cases, so this is contributing to my overall task. It just takes time. :)
  • This is on the back burner since NumberPicker has been deprecated in favor of the Generic Picker. In all likelihood, I won't be allotted any more time to look into this. Just FYI. :)
  • Former Member
    Former Member over 8 years ago
    One thing: 1 inch = 2.54 cm

    Maybe it is the cause of that limitation/bug.