GeezerVison is showing github.com — fix: allow specifying the function to be used for prompting about var… · SnoopyMod/scratch-blocks@4cfe66f
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/variables.js +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,6 +37,12 @@ import { |
37 | 37 | */ |
38 | 38 | const CLOUD_PREFIX = "☁ "; |
39 | 39 |
|
| 40 | +let prompt = null; |
| 41 | + |
| 42 | +export function setPromptHandler(handler) { |
| 43 | + prompt = handler; |
| 44 | +} |
| 45 | + |
40 | 46 | /** |
41 | 47 | * Create a new variable on the given workspace. |
42 | 48 | * @param {!Blockly.Workspace} workspace The workspace on which to create the |
@@ -70,7 +76,7 @@ export function createVariable(workspace, opt_callback, opt_type) { |
70 | 76 | var validate = nameValidator.bind(null, opt_type); |
71 | 77 |
|
72 | 78 | // Prompt the user to enter a name for the variable |
73 | | - Blockly.dialog.prompt( |
| 79 | + prompt( |
74 | 80 | newMsg, |
75 | 81 | "", |
76 | 82 | function (text, additionalVars, variableOptions) { |
@@ -309,7 +315,7 @@ export function renameVariable(workspace, variable, opt_callback) { |
309 | 315 | promptDefaultText = promptDefaultText.substring(CLOUD_PREFIX.length); |
310 | 316 | } |
311 | 317 |
|
312 | | - Blockly.dialog.prompt( |
| 318 | + prompt( |
313 | 319 | promptText, |
314 | 320 | promptDefaultText, |
315 | 321 | function (newName, additionalVars) { |
|