File tree Expand file tree Collapse file tree 5 files changed +44
-1
lines changed Expand file tree Collapse file tree 5 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,24 @@ Blockly.Blocks['simple_text_write'] = {
38
38
} ;
39
39
40
40
41
+ /**
42
+ * Write line.
43
+ */
44
+ Blockly . Blocks [ 'simple_text_writeLine' ] = {
45
+ init : function ( ) {
46
+ this . setHelpUrl ( '' ) ;
47
+ this . setColour ( 290 ) ;
48
+ this . appendValueInput ( 'text' )
49
+ . setCheck ( 'String' )
50
+ . appendField ( i18t ( 'writeLine(' ) ) ;
51
+ this . appendDummyInput ( )
52
+ . appendField ( ')' ) ;
53
+ this . setPreviousStatement ( true , [ 'Number' , 'String' ] ) ;
54
+ this . setNextStatement ( true , [ 'Number' , 'String' ] ) ;
55
+ this . setTooltip ( i18t ( 'Writes the text on its own line the screen.' ) ) ;
56
+ } ,
57
+ } ;
58
+
41
59
/**
42
60
* Draw circle.
43
61
*/
Original file line number Diff line number Diff line change @@ -30,6 +30,16 @@ Blockly.JavaScript['simple_text_write'] = function(block) {
30
30
return 'command.write(' + text + ');\n' ;
31
31
} ;
32
32
33
+ /**
34
+ * Write line.
35
+ * @param {!Blockly.block } block
36
+ * @return {string }
37
+ */
38
+ Blockly . JavaScript [ 'simple_text_writeLine' ] = function ( block ) {
39
+ let text = Blockly . JavaScript . valueToCode ( block , 'text' ,
40
+ Blockly . JavaScript . ORDER_ATOMIC ) ;
41
+ return 'command.writeLine(' + text + ');\n' ;
42
+ } ;
33
43
34
44
/**
35
45
* Draw circle.
Original file line number Diff line number Diff line change 32
32
<block type =" text" ><field name =" TEXT" ></field ></block >
33
33
</value >
34
34
</block >
35
+ <block type =" simple_text_writeLine" >
36
+ <value name =" text" >
37
+ <block type =" text" ><field name =" TEXT" ></field ></block >
38
+ </value >
39
+ </block >
35
40
</category >
36
41
37
42
<category name =" Draw" colour =" 260" >
Original file line number Diff line number Diff line change @@ -119,4 +119,4 @@ cwc.config.Sample = {
119
119
/**
120
120
* @return {string }
121
121
*/
122
- cwc . config . Version = '5.7.28 ' ;
122
+ cwc . config . Version = '5.7.29 ' ;
Original file line number Diff line number Diff line change @@ -59,6 +59,15 @@ cwc.framework.simple.Command.prototype.write = function(text) {
59
59
this . addNode_ ( goog . dom . createTextNode ( text ) ) ;
60
60
} ;
61
61
62
+ /**
63
+ * Writes a text and line break on screen.
64
+ * @param {string } text
65
+ * @export
66
+ */
67
+ cwc . framework . simple . Command . prototype . writeLine = function ( text ) {
68
+ this . addNode_ ( goog . dom . createTextNode ( text ) ) ;
69
+ this . addNode_ ( goog . dom . createElement ( 'br' ) ) ;
70
+ } ;
62
71
63
72
/**
64
73
* @param {string } title
@@ -105,6 +114,7 @@ cwc.framework.simple.Command.prototype.mapGlobal = function() {
105
114
}
106
115
window [ 'command' ] = {
107
116
'write' : this . write . bind ( this ) ,
117
+ 'writeLine' : this . writeLine . bind ( this ) ,
108
118
'showAlert' : this . showAlert . bind ( this ) ,
109
119
'showPrompt' : this . showPrompt . bind ( this ) ,
110
120
'showActionCancel' : this . showActionCancel . bind ( this ) ,
You can’t perform that action at this time.
0 commit comments