@@ -42,9 +42,8 @@ Blockly.Blocks['procedures_defnoreturn'] = {
4242 init : function ( ) {
4343 this . setHelpUrl ( Blockly . Msg . PROCEDURES_DEFNORETURN_HELPURL ) ;
4444 this . setColour ( Blockly . Blocks . procedures . HUE ) ;
45- var name = Blockly . Procedures . findLegalName (
46- Blockly . Msg . PROCEDURES_DEFNORETURN_PROCEDURE , this ) ;
47- var nameField = new Blockly . FieldTextInput ( name ,
45+ var nameField = new Blockly . FieldTextInput (
46+ Blockly . Msg . PROCEDURES_DEFNORETURN_PROCEDURE ,
4847 Blockly . Procedures . rename ) ;
4948 nameField . setSpellcheck ( false ) ;
5049 this . appendDummyInput ( )
@@ -57,6 +56,16 @@ Blockly.Blocks['procedures_defnoreturn'] = {
5756 this . setStatements_ ( true ) ;
5857 this . statementConnection_ = null ;
5958 } ,
59+ /**
60+ * Initialization of the block has completed, clean up anything that may be
61+ * inconsistent as a result of the XML loading.
62+ * @this Blockly.Block
63+ */
64+ validate : function ( ) {
65+ var name = Blockly . Procedures . findLegalName (
66+ this . getFieldValue ( 'NAME' ) , this ) ;
67+ this . setFieldValue ( name , 'NAME' ) ;
68+ } ,
6069 /**
6170 * Add or remove the statement block from this function definition.
6271 * @param {boolean } hasStatements True if a statement block is needed.
@@ -337,9 +346,8 @@ Blockly.Blocks['procedures_defreturn'] = {
337346 init : function ( ) {
338347 this . setHelpUrl ( Blockly . Msg . PROCEDURES_DEFRETURN_HELPURL ) ;
339348 this . setColour ( Blockly . Blocks . procedures . HUE ) ;
340- var name = Blockly . Procedures . findLegalName (
341- Blockly . Msg . PROCEDURES_DEFRETURN_PROCEDURE , this ) ;
342- var nameField = new Blockly . FieldTextInput ( name ,
349+ var nameField = new Blockly . FieldTextInput (
350+ Blockly . Msg . PROCEDURES_DEFRETURN_PROCEDURE ,
343351 Blockly . Procedures . rename ) ;
344352 nameField . setSpellcheck ( false ) ;
345353 this . appendDummyInput ( )
@@ -356,6 +364,7 @@ Blockly.Blocks['procedures_defreturn'] = {
356364 this . statementConnection_ = null ;
357365 } ,
358366 setStatements_ : Blockly . Blocks [ 'procedures_defnoreturn' ] . setStatements_ ,
367+ validate : Blockly . Blocks [ 'procedures_defnoreturn' ] . validate ,
359368 updateParams_ : Blockly . Blocks [ 'procedures_defnoreturn' ] . updateParams_ ,
360369 mutationToDom : Blockly . Blocks [ 'procedures_defnoreturn' ] . mutationToDom ,
361370 domToMutation : Blockly . Blocks [ 'procedures_defnoreturn' ] . domToMutation ,
0 commit comments