Avatar for RaoulDuke


Member since Dec 2021 • Last active Jul 2022
  • 12 conversations

Most recent activity

  • in Bangle.js
    Avatar for RaoulDuke

    When created, the 'Layout' object 'grabs' user input from the screen. What you'd need to do is just create a Layout object as and when you want it rather than trying to keep them in RAM all the time (it's also better for memory usage):

    Thanks, will try that!

    I don't really understand what you're asking here...

    Here is an example, i basically want to go from the main menu to the adjustment page without the intermediate menu. Is there a way to do that?

    var Layout = require("Layout");
    var a=50;
    var adjustA = {
      '< BACK>': initMainMenu,
      'A': {
        value:  a, min:0, max:100, step:1,
        format: function(value) {
          return (value);
        onchange: function(value) {
    function initMainMenu() {
      var mainMenu = new Layout (
        {type:"btn", font:"15%", fillx:1, filly:1, label:"adjust A", cb:l=>E.showMenu(adjustA)}
  • in Bangle.js
    Avatar for RaoulDuke

    I would like to use the layout library to make nested menus. When i do this:

    var mainMenu = new Layout( {
      {type:"btn", label:"A", cb:l=>{mainMenu.clear();AMenu.render();}­}
    var AMenu = new Layout( {
      {type:"btn", label:"something", cb:l=>{}}

    it shows menu "A" when i push the button, but the buttons from mainMenu are still active. Is there a simple way to completely remove a layout from screen?
    Also, i would like to change a value via the graphical menu, but without actually displaying the menu. Is there a way to do this? I could just use the menu interface, but it is difficult to use wearing gloves.

  • in Bangle.js
    Avatar for RaoulDuke

    is "Shorten variable names" enabled? If so: try diabling it.

    That worked, thanks a lot!

  • in Bangle.js
    Avatar for RaoulDuke

    Somehow, "cb:" on buttons does not work for me. When i run the code example from the tutorial, i get

    Uncaught Error: Function "a" not found!
     at line 1 col 1
    in function called from system

    I tried 2v14 as well as the bleeding edge build. Funny thing is, about 5% of the time it works as expected, but usually not. I also get this error message when uploading via the Web IDE:

    Error parsing JavaScript, but uploading anyway.
    SyntaxError: Identifier 'a' has already been declared (1:1920)

    This is the code:

    var Layout = require("Layout");
    var layout = new Layout( {
      type:"v", c: [
        {type:"txt", font:"6x8:2", label:"A Test", id:"label"},
        {type:"btn", font:"6x8:2", label:"One", cb: l=>setLabel("One") },
        {type:"btn", font:"6x8:2", label:"Two", cb: l=>setLabel("Two") }
    function setLabel(x) {
      layout.label.label = x;
  • in Bangle.js
    Avatar for RaoulDuke

    This kind of works, but the values will always be center-aligned. I have some fields that have 1-5 digits and would like them aligned to the right of their window.
    Maybe I should just write my own render function and use the coordinates provided by layout.update.

  • in Bangle.js
    Avatar for RaoulDuke

    I have a layout that displays five labels and a bar graph. I would like to update several times per second, but Layout.update takes about 0.22s to complete. Is this normal? Changing fonts from vector to bitmap did not change anything.
    As a workaround i just use g.clear() and redraw the layout completely in 0.12s. This way, i can call Layout.update just once, but then text alignments are messed up. Turns out layout uses update to calculate the position and size of a text label, then draws the text centered into it.
    I think layout should use g.setFontAlign with the correct alignment to align the labels, one call to layout.update would then be enough for many apps (where you usually don´t want your layout to change because a number is now two instead of one digit).