Layout Library Not Working

Posted on
  • I was following the tutorial of how to use the layout library:­t
    I was following the first part of the tutorial to have a basic string of text and wanted to try it out. When I pasted the code in the Web Ide and upload the code to the Bangle.js 1 emulator it gives an error:

    Uncaught Error: Function "stringMetrics" not found!
     at line 1 col 147
    ... b=g.setFont(a.font,a.fsz).stringMetrics(­a.label);a._w=b.wid...
    in function "txt" called from line 1 col 15
    ;if(f[a.type](a),a.r&1){var b=a._w;a._w=a._h,a._h=b}a._w=0|Math....
    in function "c" called from line 1 col 1093
    in function "update" called from line 1 col 197
    ....updateNeeded&&this.update();var f={'':function(){},txt:func...
    in function "render" called from line 7 col 15

    It is also weird because it says there is no errors in layout.
    Is there any way I can fix this?

    2 Attachments

    • Screenshot 2021-10-23 204513.png
    • Screenshot 2021-10-23 204616.png
  • Sun 2021.10.24

    I concur, results are the same as above for both emulator versions and also tried the example beneath images. Those errors seem to result at these lines:­lob/master/modules/Layout.js#L367­lob/master/modules/Layout.js#L374

  • Not sure if this is relevant, but after revealing using dump() line L7 appears a bit suspicious with an umlaut y object: (minification issue?)

    Layout.prototype.clear = function (l) {
      if (!l) l = this._l;
      if (l.bgCol!==undefined) g.setBgColor(l.bgCol);
    var layout = Object.create(ÿ.modules.Layout["prototyp­e"]);
    layout.l = {
      "type": "txt",
      "font": "6x8",
      "label": "Hello World"
    layout._l = {
  • Ahh, thanks - I need to update the emulator. If you try it on a real device it should be fine (as long as you updated all the other apps).

    @Robin no nothing to worry about with the umlaut - that's pretokenised code (although it should really have been converted back to text automatically)

  • Ok! Thanks!

  • Emulator is now updated

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Layout Library Not Working

Posted by Avatar for Ronin @Ronin