From 67d89761b53e8273f55ded723616ed1c0f7f8344 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Mon, 24 Apr 2023 20:47:12 +0100 Subject: [PATCH] Fix wid_edit draw() - pass WIDGET as first argument When attempting to edit a widget whose `draw` function takes the widget as an argument, we get an exception from that `draw` function. This fixes that by catering for both APIs. The back button widget expects this, as does [`widsleepstatus`], [`widlock`] and [`widlockunlock`]. There are other widgets ([`widmessages`], [`widbatpc`] and [`widalarmeta`]) which use something else for the first parameter, however these are type-checked and used to distinguish calls from `Bangle.drawWidgets()` and elsewhere. [`widsleepstatus`]: https://github.com/espruino/BangleApps/blob/2f6862024d6b92a11fd05a5183a1dd9a53dc5e48/apps/widsleepstatus/widget.js#L20 [`widlock`]: https://github.com/espruino/BangleApps/blob/2f6862024d6b92a11fd05a5183a1dd9a53dc5e48/apps/widlock/widget.js#L5 [`widlockunlock`]: https://github.com/espruino/BangleApps/blob/2f6862024d6b92a11fd05a5183a1dd9a53dc5e48/apps/widlockunlock/widget.js#L27 [`widmessages`]: https://github.com/espruino/BangleApps/blob/2f6862024d6b92a11fd05a5183a1dd9a53dc5e48/apps/widmessages/widget.js#L14 [`widbatpc`]: https://github.com/espruino/BangleApps/blob/2f6862024d6b92a11fd05a5183a1dd9a53dc5e48/apps/widbatpc/widget.js#L89 [`widalarmeta`]: https://github.com/espruino/BangleApps/blob/2f6862024d6b92a11fd05a5183a1dd9a53dc5e48/apps/widalarmeta/widget.js#L28 --- apps/wid_edit/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/wid_edit/settings.js b/apps/wid_edit/settings.js index 1d34ae0ca..be09923f2 100644 --- a/apps/wid_edit/settings.js +++ b/apps/wid_edit/settings.js @@ -67,7 +67,7 @@ function highlight() { if (WIDGET.width > 0) { // draw widget, then draw a highlighted border on top - WIDGET.draw(); + WIDGET.draw(WIDGET); g.setColor(g.theme.fgH) .drawRect(WIDGET.x, WIDGET.y, WIDGET.x+WIDGET.width-1, WIDGET.y+23); } else {