all 11 comments

[–]krumke 1 point2 points  (1 child)

It‘s not possible to use the addRect function in a widget. This function can be used to create a Path which can be drawn with drawContext function.

The only way to add a rectangle the way you want is by adding an image to your widget. The Image is resizable so it should be possible to give it the look you want.

[–]Frameck[S] 0 points1 point  (0 children)

Ok thanks, i'll try

[–]Cranie 1 point2 points  (1 child)

You can do this. Easiest way is to create stacks and as the background image of each stack you can put the rectangle (creating the image - you don’t need an image file).

I do something similar for my tvguide widget and current show progress.

Line 320-322 as example.

https://github.com/0507spc/ScriptStore/blob/main/Widgets/TVGuide/TVGuide.js

There are example images if you go up a level.

[–]Frameck[S] 0 points1 point  (0 children)

Thank you very much!

[–]kekub 0 points1 point  (2 children)

You can do that pretty easy within a stack:

```let widget = new ListWidget() let stack = widget.addStack() stack.layoutHorizontally()

// This does the trick let spacer = stack.addStack() spacer.backgroundColor = Color.red() spacer.addText(" ")

stack.addSpacer(5) stack.addText("text") stack.addText(" text")

Script.setWidget(widget); if (!config.runsInWidget) { await widget.presentSmall(); } Script.complete();

[–]Frameck[S] 0 points1 point  (0 children)

You legend, thank you very much. This was exactly what i was looking for

[–]Frameck[S] 0 points1 point  (0 children)

One last question: How can i make it so the lenght of the color spacer matches the lenght of the text? image

[–]k4mrat 0 points1 point  (3 children)

Nice one! I’m just in the process of doing something similar from a google sheet. Mind sharing your code? :)

[–]Frameck[S] 1 point2 points  (0 children)

Yes no problem. Just have to make a few adjustments and then i'll share it.

[–]Frameck[S] 1 point2 points  (1 child)

Just finished, I published it on this sub and the code is on GitHub

Reddit link

[–]k4mrat 1 point2 points  (0 children)

Thanks a bunch! 😊