@@ -6,7 +6,21 @@ Blockly.Blocks.procedures_defreturn = {
66 this . arguments = [ ] ;
77 this . argumentVarModels = [ ] ;
88
9- this . jsonInit ( {
9+ this . jsonInit ( this . definition ( ) ) ;
10+
11+ // Enforce unique procedure names
12+ const nameField = this . getField ( 'NAME' ) ;
13+ nameField . setValidator ( Blockly . Procedures . rename ) ;
14+
15+ // Render a ➕-icon for adding parameters
16+ const fieldImage = new Blockly . FieldImage ( plusIconDark , 24 , 24 , '+' , ( ) => this . onAddClick ( ) ) ;
17+ this . appendDummyInput ( 'ADD_ICON' ) . appendField ( fieldImage ) ;
18+ this . moveInputBefore ( 'ADD_ICON' , 'RETURN' ) ;
19+
20+ this . setStatements ( true ) ;
21+ } ,
22+ definition ( ) {
23+ return {
1024 message0 : translate ( 'function %1 %2 %3' ) ,
1125 message1 : 'return %1' ,
1226 args0 : [
@@ -35,18 +49,15 @@ Blockly.Blocks.procedures_defreturn = {
3549 colour : Blockly . Colours . BinaryProcedures . colour ,
3650 colourSecondary : Blockly . Colours . BinaryProcedures . colourSecondary ,
3751 colourTertiary : Blockly . Colours . BinaryProcedures . colourTertiary ,
38- } ) ;
39-
40- // Enforce unique procedure names
41- const nameField = this . getField ( 'NAME' ) ;
42- nameField . setValidator ( Blockly . Procedures . rename ) ;
43-
44- // Render a ➕-icon for adding parameters
45- const fieldImage = new Blockly . FieldImage ( plusIconDark , 24 , 24 , '+' , ( ) => this . onAddClick ( ) ) ;
46- this . appendDummyInput ( 'ADD_ICON' ) . appendField ( fieldImage ) ;
47- this . moveInputBefore ( 'ADD_ICON' , 'RETURN' ) ;
48-
49- this . setStatements ( true ) ;
52+ tooltip : translate ( 'Function def with return value' ) ,
53+ category : translate ( 'functions' ) ,
54+ } ;
55+ } ,
56+ meta ( ) {
57+ return {
58+ 'display_name' : translate ( 'Function def with return value' ) ,
59+ 'description' : translate ( 'Function def with return value Description' ) ,
60+ } ;
5061 } ,
5162 onAddClick : Blockly . Blocks . procedures_defnoreturn . onAddClick ,
5263 onchange : Blockly . Blocks . procedures_defnoreturn . onchange ,
0 commit comments