3

I am looking to use Blockly to allow non-techie users to specify test scripts.

One part of it will require a File Selector, however, I can't see that Blockly has one. Does it?

Actually, I can't find a complete list of standard blocks. Does anyone have a URL?

If there is no standard Blockly File Selector, (how) can I access the Windows File Selector? (and how, in general, can I execute DOS commands?)

Mawg says reinstate Monica
  • 38,334
  • 103
  • 306
  • 551

2 Answers2

3

As far as I know, I think that you cannot get a File Selector from Blockly but maybe this post is useful for you in which a man creates a custom Block for this purpose.

Also, I could not find a list with only the names of all the standard blocks but I saw that on the playground of Blockly you can see all the standard blocks that Google provides to you. If you want to see the code of all of them you can see it on Blockly GitHub.

I suppose that if Blockly does not have a File Selector it will not also has access to the Windows File Selector but maybe you can create a custom Block for that purpose via Javascript (I do not know what programming language are you using for). This link can help with Javascript Windows File Selector.

I expect it will be useful for you!

Community
  • 1
  • 1
Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
1

You can override the showEditor_ function on a blockly input - this works quite well with FieldTextInput. See https://youtu.be/eYHo0VeSLCI for an example of an 'intercepted' click opening a jquery mobile dialog, that then fills in the text value. The text value is then retrieved by the javascript generator to load the selected file at 'runtime'.

I've pasted below some cut down code:

Show a standard text input

let fileInput = new Blockly.FieldTextInput('** CHOOSE A FILE **')

Then you can attach a click handler which would show your file selector - so the standard browser file selector may do...

fileInput.showEditor_=(()=>alert("Intercepted"))

You'll need to replace the alert with your file selector code. Your code will also need to set the value of the text input - with something like this:

let block = Blockly.mainWorkspace.getBlockById(block_id)
block.setFieldValue(filename, widget_id)

Where widget_id identifies the text input and block_id the actual containing block.

AndyS
  • 725
  • 7
  • 17