Can anyone think of an elegant way to pop open the file dialogue?

Can anyone think of an elegant way to pop open the file dialogue?

OceanHydroAU
Collaborator Collaborator
894 Views
2 Replies
Message 1 of 3

Can anyone think of an elegant way to pop open the file dialogue?

OceanHydroAU
Collaborator
Collaborator

I'm giving users an interface to read or write data, but I need them to make decisions as well as give me a new/existing file to write/read - I can't just throw them directly into createFileDialog().

 

One idea I had, was to detect them clicking on something (e.g. "Select File") in with their options, which grabs the name of the file, then when they click "OK", it performs the complex actions based on their input with the file they gave:-

 

Screen Shot 2020-09-25 at 9.29.38 pm.png

 

However, I can't find any way to detect them clicking on anything that looks nice.  I've tried ImageCommandInput and TextBoxCommandInput (with an <img> tag) and TextBoxCommandInput that contains an HTML form - but while they all look pretty, they do nothing (I can't detect any events firing).  Ideally, does anyone know how to use JavaScript or <forms> inside TextBoxCommandInput to "talk" to my add-in?

 

Logically, I *could* wait for the "OK" and *then* ask the file, but that's going to confuse them to no-end (who clicks "OK" to import from a file, without selecting a file first? counter-intuitive!).  I could ask for the file first, but that too will confuse because the flow doesn't make sense before the other decisions they need to make.  I could use some other control, like a ButtonRowCommandInput - except that's a 16x16 pixel icon, which - while working - will basically look stupid...

 

Any ideas anyone?

0 Likes
Accepted solutions (1)
895 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

I would use a BoolValueCommandInput.  This shows up in the dialog as a button.  This is what the various import commands in Fusion use, like the "Insert DXF" command.  They use a folder icon for the button.  You can react when the button is clicked and display a file dialog to get the filename and then save that filename in a global variable.  When the OK button is clicked you can do something with the filename in the execute event.  I've attached a simple add-in that demonstrates this.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

OceanHydroAU
Collaborator
Collaborator

@Brilliant pointer - thanks Brian.  I did basically that same thing, but I prefer the icon and wording that Fusion360 is using for this same issue (thanks for pointing me at DXF!) so I'm going to change my UI to match those.

Screen Shot 2020-09-26 at 12.44.55 pm.png

 

Screen Shot 2020-09-26 at 12.44.12 pm.png

0 Likes