Which widget gets tl first ?

Posted on
  • I am wondering what controls the order in which widgets that occupy the same area are loaded / displayed. I like the lock widget to display in the extreme top left hand corner.

    Try as I might I cant get this to happen. I have tried deleting all widgets and installing them in different orders but the lock widget is displaying to the right of the 'Lato Pedometer' widget.

    The 2 widgets in the screenshot are

    • Lato Pedometer - widpb
    • Lock Widget - widlock

    Short of a factory reset is there something else I can try ?


    1 Attachment

    • download.png
  • It seems to be the sortorder attribute of the widget: https://github.com/espruino/Espruino/com­mit/8ae6fe20d99f158cac2afef5a6841048f349­dafd

    But I don't know where that comes from because I can't see it on any widget in the BangleApps repository.

  • Maybe it's species in apps.json.

  • I wondered. It is specified for some entries there, but didn't see it for the widgets you screenshot so I don't know what the fallback is in that case.

    But I also thought that might serve another purpose. Was just guessing though.

  • If there's no sortorder specified (which I implemented I believe but isn't used) the order is just the order the files happened to be listed in storage - so if you need to specify something best to just stick a sortorder in apps.json and I think that should work its way into the app info file.

  • if you need to specify something best to just stick a sortorder in apps.json

    I think you want to put it in the widget code instead: the apps.json affects the order in the App Loader page, but loadWidgets() looks at the widget.

    So something like

    WIDGETS["lock"]={area:"tl",sortorder:-1,­width:Bangle.isLocked()?16:0,...
    
  • I've done it through apps.json as that makes it more visible and standard. PR issued.

  • Did that actually work? Because as far as I can tell, loadWidgets doesn't look at the .info file, just at the sortorder defined inside the widget code.

    (Also, editing the code to change widget order seems suboptimal, so I made a widget editor)

  • as far as I can tell, loadWidgets doesn't look at the .info file, just at the sortorder defined inside the widget code.

    That's a good point! I may well have been wrong :)

  • Did that actually work?

    No it didn't work. but it was not immediately obvious as it is hard to test. Lots of installing and uninstalling etc.

    so I made a widget editor

    Just tried it out. Good job.

    editing the code to change widget order seems suboptimal

    I would agree with the exception that certain widgets (eg lock widget) should have good defaults to start with.

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

Which widget gets tl first ?

Posted by Avatar for HughB @HughB

Actions