Ui.pushView(new DeclinationPicker(), new DeclinationPickerDelegate(), Ui.SLIDE_LEFT); // number picker...
The following is my DeclinationPicker
Ui.pushView(new DeclinationPicker(), new DeclinationPickerDelegate(), Ui.SLIDE_LEFT); // number picker...
An array of number objects indicating the starting index for each entry in the supplied pattern
class DeclinationPicker extends Ui.Picker {
function initialize( ) {
var title = new Ui.Text({
:text=>"Declination",
:locX =>Ui.LAYOUT_HALIGN_CENTER,
:locY=>Ui.LAYOUT_VALIGN_BOTTOM,
:color=>Gfx.COLOR_WHITE
});
var factory = new NumberFactory(-90, 90, 0.1, {:format=>"%0.1f"});
var pattern = [
factory
];
var storedValue = App.getApp( ).getProperty("D");
// the underscore at the start of this line is to trick the forum software to allow me to post
// this code inline. just remove it.
_if (storedValue == null) {
storedValue = 0.0;
}
var defaults = [
factory.getIndex(storedValue)
];
Picker.initialize({:title=>title, :pattern=>pattern, :defaults=>defaults});
}
function onUpdate(dc) {
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
dc.clear( );
Picker.onUpdate(dc);
}
}
class DeclinationPickerDelegate extends Ui.PickerDelegate {
function initialize( ) {
PickerDelegate.initialize( );
}
function onCancel( ) {
Ui.popView(Ui.SLIDE_IMMEDIATE);
}
function onAccept(values) {
// again, there is one entry in your pattern, so there will be one entry in
// the values array.
App.getApp( ).setProperty("D", values[0]);
Ui.popView(Ui.SLIDE_IMMEDIATE);
}
}
function getIndex(value) {
var index;
//index = ( value / mIncrement ) - mStart; // this line seems wrong
index = (value - mStart) / mIncrement; // this one works
return index;
}