setImageURL vs drawImageURL

I want to be able to click on an image to provide more info on the picture - currently using spacexdata crew info, driven by the spacexdata API and JSON results, clicking on the crew member picture e.g. I am perfectly able to load that URL into a canvas using drawImageURL(url).

However, I can’t seem to get onEvent(“myCanvas”,“click”, handleCanvasClickFunction) to work - it doesn’t ever generate an event when I click on the canvas.

As a workaround, I tried using a Button with an image instead, but this refuses to load the image URL! It appears not to be able to load any image programmatically. It does load the image if I specify it in the Design mode.

Is this a bug/feature, or am I missing something - on both counts!

  • clicking on a canvas doesn’t raise an event
  • setImageURL() won’t load URLs programmatically

The setImageURL problem is demonstrated in - App Lab

OK. I think I understand this.

  1. I should be using an Image for the image (really!) - then click events work, and it loads any image.

  2. setImageUrl() probably only works for Image widgets, others (screens, buttons) maybe won’t load programmatically??

Here is a link to App Lab Docs: App Lab Docs
drawImageURL & setImageURL don’t allow you to link to outside data.
However, check the open ( ) block feature here.
Please let us know if you need further assistance.

Thanks for that. Reading the Image documentation, it says " 1. Copy the URL of an image on the web." as an option for populating Images. And that works, for Image and Canvas both statically configured and programmatically. The images for other widgets (buttons, screens…) can only be statically configured - the docs for setImageURL (bit of a clue in the name!) say “Sets the URL for the specified image element id.”

As far as I can see, it’s only the startWebRequest that’s limited to a pre-configured set of URLs. For images and open(), you can point to anything.

You can change a button’s image with setProperty("button1", "image", ""); That also works for screens. It does not work for a canvas.

You can see what elements can have an image by using the drop down in block mode using the setProperty function after selecting an element id. Prior to selecting an element id the drop down contains properties your element doesn’t have.

startWebRequest() doesn’t work for all of the listed sites. The white listed sites often change interface and App Lab isn’t able to keep up with changes. So no help there.

Terence is correct, open() is your best option for what you want. App Lab tries to keep inappropriate apps to a minimum.

Another thing to consider is creating a database of the information you want. You can scrap the website into a CSV file and then load it all.