Added general support for modal windows for variable rename/creation#396
Added general support for modal windows for variable rename/creation#396MarkusBordihn wants to merge 1 commit intoRaspberryPiFoundation:masterfrom MarkusBordihn:hotfix-variables
Conversation
|
There seems to be more unwanted changes in this PR, are you sure you were working on up-to-date master? |
|
Sorry forgot to reset my branch, should be fixed now. |
core/options.js
Outdated
| hasCss = true; | ||
| } | ||
| var hasModal = options['modal']; | ||
| if (hasModal === undefined) { |
There was a problem hiding this comment.
Is this meant to be a callback to a modal then? If that's the case we need to make sure the interface is clearly defined.
There was a problem hiding this comment.
Good point, checked the current code and it seems we need something for:
- window.alert
- window.prompt
- window.confirm
I will prepare this PR to support multiple version and the changes could be added in other PR if needed.
|
I've added a couple of comments, but I haven't tested it as it is quite late on this side of the pond, I'll see if I can find some time tomorrow. |
…sed in #393. Added inject option "modal" which is used instead of window.prompt.
|
Thanks for your comments, added some additional changes and was able to solve some edge cases as well. The new "modal" could be used to pass over modal functions for:
The expected format of these are the standard definition + callback (if needed) + opt title e.g. confirm prompt Currently the modal options is only implemented for variable renaming and creation, but could be expand to any other function as well. If the option is not set, the systems defaults are used. |
|
@NeilFraser |
|
@NeilFraser |
|
FYI, @rachel-fenichel is working on a new model for variable management. It is designed to optionally support typed variables so that C/Java/Fortran can be generated properly. The existing system was a quick and dirty implementation that lasted far longer than could have been predicted. I think it best to make one change to Rachel's new system, than change the system twice in succession. |
|
Any general ETA for the new variable system? |
|
Eta: sometime this summer. Discussion at #446 |
This change will allow to pass over modal functions for:
The expected format of these are the standard definition + callback (if needed) + opt title e.g.
alert
function(message, opt_title) { ...}confirm
function(message, callback, opt_title) { callback(result); }prompt
function(message, default, callback, opt_title) { callback(result); }Example config
Blockly.inject(node, { modal: { alert: function(...) {...}, confirm: function(...) {...}, prompt: function(...) {...} } });All my test works fine, with and without the modal parameter.