Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
0d585f17
Commit
0d585f17
authored
Apr 24, 2020
by
Beka Westberg
Committed by
Evan W. Patton
May 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add text bumping when number is replaced w/ text
parent
dc0307cc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
7 deletions
+47
-7
appinventor/blocklyeditor/src/blocks/text.js
appinventor/blocklyeditor/src/blocks/text.js
+47
-7
No files found.
appinventor/blocklyeditor/src/blocks/text.js
View file @
0d585f17
...
...
@@ -19,10 +19,15 @@ Blockly.Blocks['text'] = {
category
:
'
Text
'
,
helpUrl
:
Blockly
.
Msg
.
LANG_TEXT_TEXT_HELPURL
,
init
:
function
()
{
var
textInput
=
new
Blockly
.
FieldTextInput
(
''
);
textInput
.
onFinishEditing_
=
Blockly
.
Blocks
.
text
.
bumpBlockOnFinishEdit
.
bind
(
this
);
this
.
setColour
(
Blockly
.
TEXT_CATEGORY_HUE
);
this
.
appendDummyInput
().
appendField
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_LEFT_QUOTE
).
appendField
(
new
Blockly
.
FieldTextBlockInput
(
''
),
'
TEXT
'
).
appendField
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_RIGHT_QUOTE
);
this
.
appendDummyInput
()
.
appendField
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_LEFT_QUOTE
)
.
appendField
(
textInput
,
'
TEXT
'
)
.
appendField
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_RIGHT_QUOTE
);
this
.
setOutput
(
true
,
[
Blockly
.
Blocks
.
text
.
connectionCheck
]);
this
.
setTooltip
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_TOOLTIP
);
},
...
...
@@ -53,6 +58,36 @@ Blockly.Blocks.text.connectionCheck = function (myConnection, otherConnection) {
return
false
;
};
/**
* Bumps the text block out of its connection iff it is connected to a number
* input and it no longer contains a number.
* @param {string} finalValue The final value typed into the text input.
* @this Blockly.Block
*/
Blockly
.
Blocks
.
text
.
bumpBlockOnFinishEdit
=
function
(
finalValue
)
{
var
connection
=
this
.
outputConnection
.
targetConnection
;
if
(
!
connection
)
{
return
;
}
if
(
!
isNaN
(
parseFloat
(
finalValue
)))
{
// Block is a number, so no matter where it lives it is valid.
return
;
}
var
typeArray
=
connection
.
check_
;
var
length
=
typeArray
.
length
;
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
var
type
=
typeArray
[
i
];
if
(
type
==
"
String
"
||
type
==
"
Key
"
)
{
// There is another valid type on the connection.
return
;
}
}
connection
.
disconnect
();
connection
.
sourceBlock_
.
bumpNeighbours_
();
}
Blockly
.
Blocks
[
'
text_join
'
]
=
{
// Create a string made up of any number of elements of any type.
// TODO: (Andrew) Make this handle multiple arguments.
...
...
@@ -473,10 +508,15 @@ Blockly.Blocks['obfuscated_text'] = {
helpUrl
:
Blockly
.
Msg
.
LANG_TEXT_TEXT_OBFUSCATE_HELPURL
,
init
:
function
()
{
this
.
setColour
(
Blockly
.
TEXT_CATEGORY_HUE
);
this
.
appendDummyInput
().
appendField
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_OBFUSCATE
+
"
"
+
Blockly
.
Msg
.
LANG_TEXT_TEXT_LEFT_QUOTE
).
appendField
(
new
Blockly
.
FieldTextBlockInput
(
''
),
'
TEXT
'
).
appendField
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_RIGHT_QUOTE
);
var
label
=
Blockly
.
Msg
.
LANG_TEXT_TEXT_OBFUSCATE
+
"
"
+
Blockly
.
Msg
.
LANG_TEXT_TEXT_LEFT_QUOTE
var
textInput
=
new
Blockly
.
FieldTextBlockInput
(
''
);
textInput
.
onFinishEditing_
=
Blockly
.
Blocks
.
text
.
bumpBlockOnFinishEdit
.
bind
(
this
);
this
.
appendDummyInput
()
.
appendField
(
label
)
.
appendField
(
textInput
,
'
TEXT
'
)
.
appendField
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_RIGHT_QUOTE
);
this
.
setOutput
(
true
,
[
Blockly
.
Blocks
.
text
.
connectionCheck
]);
this
.
setTooltip
(
Blockly
.
Msg
.
LANG_TEXT_TEXT_OBFUSCATE_TOOLTIP
);
this
.
confounder
=
Math
.
random
().
toString
(
36
).
replace
(
/
[^
a-z
]
+/g
,
''
).
substr
(
0
,
8
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment