question

Sergio V6 avatar image
0 Likes"
Sergio V6 asked Sergio V6 commented

Download in the Embedded web browser

Hello

I modify the Start Page to show a collection simulation templates.

1626809832173.pngapproved.png

But when I click the download button it do nothing, when I opened in chrome, firefox or IE i dont have problems. there is a way to download something from the flexsim web browser? or it's not supported.


Thanks!

FlexSim 21.0.2
flexsim 21.0.2downloadweb browser
1626809832173.png (89.3 KiB)
approved.png (12.3 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ben Wilson avatar image
0 Likes"
Ben Wilson answered Sergio V6 commented

There is a workaround that involves using Chromium and FlexScript together. For example, clicking the upgrade button on the start page does initiate an installer download:

1633465215417.png

The key is that your link's onclick event needs to call a FlexScript function that initiates the download. For instance, the onclick event of the start page's update "lightbulb" icon calls the following JavaScript:

fireFlexsimEvent("onClickDownload", this.getAttribute('data-href'),                             this.getAttribute('name'), this.id, this.getAttribute('category'), this.getAttribute('filename'));

You can see that we're storing the parameters needed for that onClickDownload() FlexScript function as attributes on the lightbulb DOM element. We read those out via JS and pass them to the FlexScript function call.

You can view the old-school FlexScript code for the onClickDownload() function here:

VIEW:/guiclasses/WebPanel>eventfunctions/onClickDownload

The code there automatically saves the download to a "downloads" folder under FlexSim's documentsdir(), but you could choose to call filebrowse() or do something altogether different for your download save destination.

Continuing to examine the onClickDownload code, you'll see we set up a callback, and then call the downloadfile application command.

It gets kind of arcane, but if you follow the code and check out what is going on in the tree, you should be able to reproduce this behavior for your own purpose.

Good luck!


1633465215417.png (222.0 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·
You can search this community for some examples using fireFlexsimEvent.
0 Likes 0 ·
Sergio V6 avatar image Sergio V6 commented ·
Thank you! I will try this.
0 Likes 0 ·
Phil BoBo avatar image
0 Likes"
Phil BoBo answered

The embedded web browser widget does not currently support downloading files directly. I will add a case to the dev list to consider implementing a download handler for a future version.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.