@@ -30,148 +30,150 @@ goog.require('Blockly.Blocks');
30
30
goog . require ( 'Blockly.Types' ) ;
31
31
32
32
Blockly . Blocks [ 'variables_get' ] = {
33
- /**
34
- * Block for variable getter.
35
- * @this Blockly.Block
36
- */
37
- init : function ( ) {
38
- this . setHelpUrl ( Blockly . Msg . VARIABLES_GET_HELPURL ) ;
39
- this . setColour ( Blockly . Blocks . variables . HUE ) ;
40
- this . appendDummyInput ( )
33
+ /**
34
+ * Block for variable getter.
35
+ * @this Blockly.Block
36
+ */
37
+ init : function ( ) {
38
+ this . setHelpUrl ( Blockly . Msg . VARIABLES_GET_HELPURL ) ;
39
+ this . setColour ( Blockly . Blocks . variables . HUE ) ;
40
+ this . appendDummyInput ( )
41
41
. appendField ( new Blockly . FieldVariable ( Blockly . Msg . VARIABLES_DEFAULT_NAME ) , 'VAR' ) ;
42
- this . setOutput ( true ) ;
43
- this . setTooltip ( Blockly . Msg . VARIABLES_GET_TOOLTIP ) ;
44
- this . contextMenuMsg_ = Blockly . Msg . VARIABLES_GET_CREATE_SET ;
45
- } ,
46
- contextMenuType_ : 'variables_set' ,
47
- /**
48
- * Add menu option to create getter/setter block for this setter/getter.
49
- * @param {!Array } options List of menu options to add to.
50
- * @this Blockly.Block
51
- */
52
- customContextMenu : function ( options ) {
53
- var option = { enabled : true } ;
54
- var name = this . getFieldValue ( 'VAR' ) ;
55
- option . text = this . contextMenuMsg_ . replace ( '%1' , name ) ;
56
- var xmlField = goog . dom . createDom ( 'field' , null , name ) ;
57
- xmlField . setAttribute ( 'name' , 'VAR' ) ;
58
- var xmlBlock = goog . dom . createDom ( 'block' , null , xmlField ) ;
59
- xmlBlock . setAttribute ( 'type' , this . contextMenuType_ ) ;
60
- option . callback = Blockly . ContextMenu . callbackFactory ( this , xmlBlock ) ;
61
- options . push ( option ) ;
62
- } ,
63
- /**
64
- * @return {!string } Retrieves the type (stored in varType) of this block.
65
- * @this Blockly.Block
66
- */
67
- getBlockType : function ( ) {
68
- return [ Blockly . Types . UNDEF , this . getFieldValue ( 'VAR' ) ] ;
69
- } ,
70
- /**
71
- * Gets the stored type of the variable indicated in the argument. As only one
72
- * variable is stored in this block, no need to check input
73
- * @this Blockly.
74
- * @param {!string } varName Name of this block variable to check type.
75
- * @return {!string } String to indicate the type of this block.
76
- */
77
- getVarType : function ( varName ) {
78
- //return [Blockly.Types.UNDEF, this.getFieldValue('VAR')];
79
- return Blockly . Types . getChildBlockType ( this )
80
- }
42
+ this . setOutput ( true ) ;
43
+ this . setTooltip ( Blockly . Msg . VARIABLES_GET_TOOLTIP ) ;
44
+ this . contextMenuMsg_ = Blockly . Msg . VARIABLES_GET_CREATE_SET ;
45
+ } ,
46
+ contextMenuType_ : 'variables_set' ,
47
+ /**
48
+ * Add menu option to create getter/setter block for this setter/getter.
49
+ * @param {!Array } options List of menu options to add to.
50
+ * @this Blockly.Block
51
+ */
52
+ customContextMenu : function ( options ) {
53
+ var option = {
54
+ enabled : true
55
+ } ;
56
+ var name = this . getFieldValue ( 'VAR' ) ;
57
+ option . text = this . contextMenuMsg_ . replace ( '%1' , name ) ;
58
+ var xmlField = goog . dom . createDom ( 'field' , null , name ) ;
59
+ xmlField . setAttribute ( 'name' , 'VAR' ) ;
60
+ var xmlBlock = goog . dom . createDom ( 'block' , null , xmlField ) ;
61
+ xmlBlock . setAttribute ( 'type' , this . contextMenuType_ ) ;
62
+ option . callback = Blockly . ContextMenu . callbackFactory ( this , xmlBlock ) ;
63
+ options . push ( option ) ;
64
+ } ,
65
+ /**
66
+ * @return {!string } Retrieves the type (stored in varType) of this block.
67
+ * @this Blockly.Block
68
+ */
69
+ getBlockType : function ( ) {
70
+ return [ Blockly . Types . UNDEF , this . getFieldValue ( 'VAR' ) ] ;
71
+ } ,
72
+ /**
73
+ * Gets the stored type of the variable indicated in the argument. As only one
74
+ * variable is stored in this block, no need to check input
75
+ * @this Blockly.
76
+ * @param {!string } varName Name of this block variable to check type.
77
+ * @return {!string } String to indicate the type of this block.
78
+ */
79
+ getVarType : function ( varName ) {
80
+ //return [Blockly.Types.UNDEF, this.getFieldValue('VAR')];
81
+ return Blockly . Types . getChildBlockType ( this )
82
+ }
81
83
} ;
82
84
83
85
Blockly . Blocks [ 'variables_set' ] = {
84
- /**
85
- * Block for variable setter.
86
- * @this Blockly.Block
87
- */
88
- init : function ( ) {
89
- this . appendValueInput ( "VALUE" )
90
- . appendField ( Blockly . Msg . VARIABLES_SET )
91
- . appendField ( new Blockly . FieldVariable ( Blockly . Msg . VARIABLES_DEFAULT_NAME ) , 'VAR' )
92
- . appendField ( Blockly . Msg . _AT ) ;
93
- this . setHelpUrl ( Blockly . Msg . HELPURL ) ;
94
- this . setTooltip ( Blockly . Msg . VARIABLES_SET_TOOLTIP ) ;
95
- this . setColour ( Blockly . Blocks . variables . HUE ) ;
96
- this . setPreviousStatement ( true , null ) ;
97
- this . setNextStatement ( true , null ) ;
98
- this . contextMenuMsg_ = Blockly . Msg . VARIABLES_SET_CREATE_GET ;
99
- } ,
100
- contextMenuType_ : 'variables_get' ,
101
- customContextMenu : Blockly . Blocks [ 'variables_get' ] . customContextMenu ,
102
- /**
103
- * Searches through the nested blocks to find a variable type.
104
- * @this Blockly.Block
105
- * @param {!string } varName Name of this block variable to check type.
106
- * @return {string } String to indicate the type of this block.
107
- */
108
- getVarType : function ( varName ) {
109
- return Blockly . Types . getChildBlockType ( this ) ;
110
- }
86
+ /**
87
+ * Block for variable setter.
88
+ * @this Blockly.Block
89
+ */
90
+ init : function ( ) {
91
+ this . appendValueInput ( "VALUE" )
92
+ . appendField ( Blockly . Msg . VARIABLES_SET )
93
+ . appendField ( new Blockly . FieldVariable ( Blockly . Msg . VARIABLES_DEFAULT_NAME ) , 'VAR' )
94
+ . appendField ( Blockly . Msg . _AT ) ;
95
+ this . setHelpUrl ( Blockly . Msg . HELPURL ) ;
96
+ this . setTooltip ( Blockly . Msg . VARIABLES_SET_TOOLTIP ) ;
97
+ this . setColour ( Blockly . Blocks . variables . HUE ) ;
98
+ this . setPreviousStatement ( true , null ) ;
99
+ this . setNextStatement ( true , null ) ;
100
+ this . contextMenuMsg_ = Blockly . Msg . VARIABLES_SET_CREATE_GET ;
101
+ } ,
102
+ contextMenuType_ : 'variables_get' ,
103
+ customContextMenu : Blockly . Blocks [ 'variables_get' ] . customContextMenu ,
104
+ /**
105
+ * Searches through the nested blocks to find a variable type.
106
+ * @this Blockly.Block
107
+ * @param {!string } varName Name of this block variable to check type.
108
+ * @return {string } String to indicate the type of this block.
109
+ */
110
+ getVarType : function ( varName ) {
111
+ return Blockly . Types . getChildBlockType ( this ) ;
112
+ }
111
113
} ;
112
114
113
115
Blockly . Blocks [ 'variables_set_type' ] = {
114
- /**
115
- * Block for variable casting.
116
- * @this Blockly.Block
117
- */
118
- init : function ( ) {
119
- this . setHelpUrl ( 'http://arduino.cc/en/Reference/HomePage' ) ;
120
- this . setColour ( Blockly . Blocks . variables . HUE ) ;
121
- this . appendValueInput ( 'VARIABLE_SETTYPE_INPUT' ) ;
122
- this . appendDummyInput ( )
116
+ /**
117
+ * Block for variable casting.
118
+ * @this Blockly.Block
119
+ */
120
+ init : function ( ) {
121
+ this . setHelpUrl ( 'http://arduino.cc/en/Reference/HomePage' ) ;
122
+ this . setColour ( Blockly . Blocks . variables . HUE ) ;
123
+ this . appendValueInput ( 'VARIABLE_SETTYPE_INPUT' ) ;
124
+ this . appendDummyInput ( )
123
125
. appendField ( Blockly . Msg . VARIABLES_AS )
124
126
. appendField ( new Blockly . FieldDropdown (
125
- Blockly . Types . getValidTypeArray ( ) ) , 'VARIABLE_SETTYPE_TYPE' ) ;
126
- this . setInputsInline ( true ) ;
127
- this . setOutput ( true ) ;
128
- this . setTooltip ( 'Sets a value to a specific type' ) ;
129
- } ,
130
- /**
131
- * Assigns a type to the block based on the selected type to cast.
132
- * @return {!string } Blockly type for this block configuration.
133
- * @this Blockly.Block
134
- */
135
- getBlockType : function ( ) {
136
- var blocklyTypeKey = this . getFieldValue ( 'VARIABLE_SETTYPE_TYPE' ) ;
137
- return Blockly . Types [ blocklyTypeKey ] ;
138
- }
127
+ Blockly . Types . getValidTypeArray ( ) ) , 'VARIABLE_SETTYPE_TYPE' ) ;
128
+ this . setInputsInline ( true ) ;
129
+ this . setOutput ( true ) ;
130
+ this . setTooltip ( 'Sets a value to a specific type' ) ;
131
+ } ,
132
+ /**
133
+ * Assigns a type to the block based on the selected type to cast.
134
+ * @return {!string } Blockly type for this block configuration.
135
+ * @this Blockly.Block
136
+ */
137
+ getBlockType : function ( ) {
138
+ var blocklyTypeKey = this . getFieldValue ( 'VARIABLE_SETTYPE_TYPE' ) ;
139
+ return Blockly . Types [ blocklyTypeKey ] ;
140
+ }
139
141
} ;
140
142
141
143
Blockly . Blocks [ 'variables_const' ] = {
142
- init : function ( ) {
144
+ init : function ( ) {
143
145
this . appendValueInput ( "VAL_CONST" )
144
- . appendField ( Blockly . Msg . VARIABLES_SET_CONST )
145
- . appendField ( new Blockly . FieldVariable ( Blockly . Msg . VARIABLES_DEFAULT_NAME ) , 'VAR' )
146
- . appendField ( Blockly . Msg . VARIABLES_SET_CONST_AT ) ;
146
+ . appendField ( Blockly . Msg . VARIABLES_SET_CONST )
147
+ . appendField ( new Blockly . FieldVariable ( Blockly . Msg . VARIABLES_DEFAULT_NAME ) , 'VAR' )
148
+ . appendField ( Blockly . Msg . VARIABLES_SET_CONST_AT ) ;
147
149
this . setColour ( Blockly . Blocks . variables . HUE ) ;
148
150
this . setPreviousStatement ( true , null ) ;
149
151
this . setNextStatement ( true , null ) ;
150
152
this . setTooltip ( Blockly . Msg . VARIABLES_SET_CONST_TOOLTIP ) ;
151
153
this . setHelpUrl ( Blockly . Msg . VARIABLES_SET_CONST_HELPURL ) ;
152
154
this . contextMenuMsg_ = Blockly . Msg . VARIABLES_SET_CREATE_GET ;
153
- } ,
154
- contextMenuType_ : 'variables_get' ,
155
- customContextMenu : Blockly . Blocks [ 'variables_get' ] . customContextMenu ,
156
- /**
157
- * Searches through the nested blocks to find a variable type.
158
- * @this Blockly.Block
159
- * @param {!string } varName Name of this block variable to check type.
160
- * @return {string } String to indicate the type of this block.
161
- */
162
- getVarType : function ( varName ) {
163
- return Blockly . Types . getChildBlockType ( this ) ;
164
- }
155
+ } ,
156
+ contextMenuType_ : 'variables_get' ,
157
+ customContextMenu : Blockly . Blocks [ 'variables_get' ] . customContextMenu ,
158
+ /**
159
+ * Searches through the nested blocks to find a variable type.
160
+ * @this Blockly.Block
161
+ * @param {!string } varName Name of this block variable to check type.
162
+ * @return {string } String to indicate the type of this block.
163
+ */
164
+ getVarType : function ( varName ) {
165
+ return Blockly . Types . getChildBlockType ( this ) ;
166
+ }
165
167
} ;
166
168
167
169
Blockly . Blocks [ 'variables_set_init' ] = {
168
- init : function ( ) {
170
+ init : function ( ) {
169
171
this . appendValueInput ( "VALUE" )
170
- . appendField ( Blockly . Msg . VARIABLES_SET_INIT )
171
- . appendField ( new Blockly . FieldVariable ( Blockly . Msg . VARIABLES_DEFAULT_NAME ) , 'VAR' )
172
- . appendField ( Blockly . Msg . VARIABLES_AS )
173
- . appendField ( new Blockly . FieldDropdown ( Blockly . Types . getValidTypeArray ( ) ) , 'VARIABLE_SETTYPE_TYPE' )
174
- . appendField ( Blockly . Msg . _AT ) ;
172
+ . appendField ( Blockly . Msg . VARIABLES_SET_INIT )
173
+ . appendField ( new Blockly . FieldVariable ( Blockly . Msg . VARIABLES_DEFAULT_NAME ) , 'VAR' )
174
+ . appendField ( Blockly . Msg . VARIABLES_AS )
175
+ . appendField ( new Blockly . FieldDropdown ( Blockly . Types . getValidTypeArray ( ) ) , 'VARIABLE_SETTYPE_TYPE' )
176
+ . appendField ( Blockly . Msg . _AT ) ;
175
177
this . setPreviousStatement ( true , null ) ;
176
178
this . setNextStatement ( true , null ) ;
177
179
this . setColour ( Blockly . Blocks . variables . HUE ) ;
@@ -187,7 +189,7 @@ Blockly.Blocks['variables_set_init'] = {
187
189
* @param {!string } varName Name of this block variable to check type.
188
190
* @return {string } String to indicate the type of this block.
189
191
*/
190
- getVarType : function ( varName ) {
191
- return Blockly . Types . getChildBlockType ( this ) ;
192
+ getVarType : function ( varName ) {
193
+ return Blockly . Types . getChildBlockType ( this ) ;
192
194
}
193
- } ;
195
+ } ;
0 commit comments