when create get/set dynamic variable block from set/get ,
lost the type.
This commit is contained in:
duzc2dtw@gmail.com
2018-09-11 00:44:27 +08:00
parent f523939d5f
commit 6e589e3491

View File

@@ -102,11 +102,14 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
}
var opposite_type;
var contextMenuMsg;
var varType;
if (this.type == 'variables_get_dynamic') {
opposite_type = 'variables_set_dynamic';
varType = this.outputConnection.check_ ? this.outputConnection.check_[0] : "";
contextMenuMsg = Blockly.Msg['VARIABLES_GET_CREATE_SET'];
} else {
opposite_type = 'variables_get_dynamic';
varType = this.inputList[0].connection.check_ ? this.inputList[0].connection.check_[0] : "";
contextMenuMsg = Blockly.Msg['VARIABLES_SET_CREATE_GET'];
}
@@ -115,6 +118,7 @@ Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MI
option.text = contextMenuMsg.replace('%1', name);
var xmlField = document.createElement('field');
xmlField.setAttribute('name', 'VAR');
xmlField.setAttribute('variabletype', varType);
xmlField.appendChild(document.createTextNode(name));
var xmlBlock = document.createElement('block');
xmlBlock.setAttribute('type', opposite_type);