Number Picker doesn't work as expected

Hi, I setup a new picker according to the picker example:
var dayFactory = new NumberFactory(1,31,1, {});
Picker.initialize({:title=>title, :pattern=>[dayFactory], :defaults=> [dayFactory.getIndex(21).toNumber()] });


The picker is not initialized with 21 (I tried also to write directly 21 to the defaults array) but shows an at least 3 digits value ( I can't read the entire string since the font is too large, but it's definitely string with more than two characters although my defined range is 1 to 31).

If I omit the default, the picker works as expected. What is wrong with my implementaion? Any thougts?
  • I don't see anything wrong with your code. I copy/pasted it into samples/Picker/source/TimePicker.mc and got the expected behavior (initial displayed value is 21)...

    class TimePicker extends WatchUi.Picker {

    function initialize() {

    var title = new WatchUi.Text({:text=>Rez.Strings.timePickerTitle, :locX=>WatchUi.LAYOUT_HALIGN_CENTER, :locY=>WatchUi.LAYOUT_VALIGN_BOTTOM, :color=>Graphics.COLOR_WHITE});

    var dayFactory = new NumberFactory(1, 31, 1, {});
    Picker.initialize({:title=>title, :pattern=>[dayFactory] , :defaults=> [dayFactory.getIndex(21).toNumber()] });
    }

    function onUpdate(dc) {
    dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
    dc.clear();
    Picker.onUpdate(dc);
    }
    }

    class TimePickerDelegate extends WatchUi.PickerDelegate {

    function initialize() {
    PickerDelegate.initialize();
    }

    function onCancel() {
    WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
    }

    function onAccept(values) {
    System.println(values);

    WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
    }

    }


    are you running into problems on a device?