Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Why is the rectangle not showing on the widget?

Since I am still learning the basics of JavaScript, can someone suggest me a possible way to solve the error of this Scriptable code? (I am trying to draw a simple rectangle at the centre of the widget).

Please, I don’t want to write the solution code, but to explain me, if possible, what I have done wrong and how can I do it better, after all, as I said, I am still learning the new language.

CODE:

async function createCentralRect(w, h) {
  let newRect = new Rect(0, 0, w, h)
  return newRect
}

async function createWidget() {
  let widget = new ListWidget()

  let rect = await createCentralRect(2, 2)
  let cnv = new DrawContext()
  let rectColor = new Color("#000")
  cnv.fillRect(rect)
  cnv.setFillColor(rectColor)
  return widget
}

let widget = await createWidget()
if (config.runsInWidget) {
  Script.setWidget(widget)
} else {
  widget.presentSmall()
}
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!