Return string from compute in Toybox::WatchUi::SimpleDataField ?

According to the docs ( http://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/WatchUi/SimpleDataField.html ) you should be able to return a string from the compute method in Toybox::WatchUi::SimpleDataField ; "Allowed types are Number, Float, Long, Double, and String".

However a can't get a simple test like
class SimpleDataView extends Ui.SimpleDataField {
function initialize() {
label = "test";
}

function compute(info) {
//return 1;
//return 3.14;
return "hello";
}
}

to work. Returning 1 or 3.14 works like expected.
Bug in current SDK?
  • Former Member
    Former Member over 10 years ago
    Yeah, the 0.1.1 version of the simulator doesn't have support for strings. I think I may have missed adding this into the known issues in the readme. We will be supporting strings in a future release of the SDK.
  • Thanks!
    Yes, the known issues part is rather short in the README. It only mentions colors being wrong in the simulator. :)
  • Former Member
    Former Member over 10 years ago
    Any news on when strings support is going to be added? Thanks
  • No, and I have doubts that Garmin will commit to having it done for any specific time frame unless it is already completed. All we (the general public) know at this time is that they intend to have an update in December and another one after the new year. For the time being, it isn't incredibly difficult to work around the problem (extend Ui.DataField and implement onUpdate() to render text).
  • FWIW, using a DataField instead of a SimpleDataField and rendering your string yourself is very simple.
  • Sure, it's not that hard, but still some things to consider. High level stuff like this makes it hard to screw up.
    You need to draw the main text and the label in the correct size. Available size depends on device and number of fields. Possibly also different label position depending on square or round watch. And maybe pick the right font and color to match the watch's theme. Now it's just the 920xt, but in the future there will be a lot more and then it's very nice to don't have to bother with details for every device.
  • Sure. Garmin has confirmed this is a known issue, so they plan to fix it. In the interrim, just work around it and move on. When the fix comes, delete all of your rendering code.
  • There's also possible gains in memory footprint, speed and energy efficiency by using Garmin provided code instead of every app using their own custom code.

    I don't have a project yet, just toying around. So I don't have anything better to do than complaining :)