@@ -318,7 +318,7 @@ const CALL_PYTHON_FUNCTION = {
318318 this . mrcMechanismId = extraState . mechanismId ? extraState . mechanismId : '' ;
319319 this . mrcComponentClassName = extraState . componentClassName ? extraState . componentClassName : '' ;
320320 this . mrcMechanismClassName = extraState . mechanismClassName ? extraState . mechanismClassName : '' ;
321- // Initialize mrcComponentNames and mrcMapComponentNameToId here. They will be filled during mrcOnLoad .
321+ // Initialize mrcComponentNames and mrcMapComponentNameToId here. They will be filled during mrcValidate .
322322 this . mrcComponentNames = [ ] ;
323323 this . mrcMapComponentNameToId = { } ;
324324 this . updateBlock_ ( ) ;
@@ -405,7 +405,7 @@ const CALL_PYTHON_FUNCTION = {
405405 . appendField ( '.' ) ;
406406 }
407407 // Here we create a text field for the component name.
408- // Later, in mrcOnLoad , we will replace it with a dropdown.
408+ // Later, in mrcValidate , we will replace it with a dropdown.
409409 titleInput
410410 . appendField ( createFieldNonEditableText ( '' ) , FIELD_COMPONENT_NAME )
411411 . appendField ( '.' )
@@ -565,8 +565,18 @@ const CALL_PYTHON_FUNCTION = {
565565 }
566566 return components ;
567567 } ,
568+ /**
569+ * mrcOnLoad is called for each CallPythonFunctionBlock when the blocks are loaded in the blockly
570+ * workspace.
571+ */
568572 mrcOnLoad : function ( this : CallPythonFunctionBlock ) : void {
569- // mrcOnLoad is called for each CallPythonFunctionBlock when the blocks are loaded in the blockly workspace.
573+ this . mrcValidate ( ) ;
574+ } ,
575+ /**
576+ * mrcValidate checks the block, updates it, and/or adds a warning balloon if necessary.
577+ * It is called from mrcOnLoad above and from Editor.makeCurrent.
578+ */
579+ mrcValidate : function ( this : CallPythonFunctionBlock ) : void {
570580 const editor = Editor . getEditorForBlocklyWorkspace ( this . workspace , true /* returnCurrentIfNotFound */ ) ;
571581 if ( ! editor ) {
572582 return ;
0 commit comments