typed variables working partially
This commit is contained in:
parent
136b85e027
commit
3e3f0be41f
@ -12,6 +12,10 @@ const setVariableFunction = function (defaultValue) {
|
||||
Blockly['Arduino'].ORDER_ATOMIC
|
||||
);
|
||||
|
||||
const allVars = Blockly.getMainWorkspace().getVariableMap().getAllVariables();
|
||||
const myVar = allVars.filter(v => v.name === variableName)[0]
|
||||
|
||||
Blockly.Arduino.setupCode_[''] = myVar.type + " " + myVar.name + ';\n';
|
||||
return variableName + ' = ' + (variableValue || defaultValue) + ';\n';
|
||||
};
|
||||
};
|
||||
@ -25,14 +29,5 @@ const getVariableFunction = function (block) {
|
||||
return [variableName, Blockly['Arduino'].ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly['Arduino']['variables_set_number'] = setVariableFunction(10);
|
||||
Blockly['Arduino']['variables_set_boolean'] = setVariableFunction('true');
|
||||
Blockly['Arduino']['variables_set_string'] = setVariableFunction('" "');
|
||||
Blockly['Arduino']['variables_set_colour'] = setVariableFunction(
|
||||
`{ 22, 0, 22}`
|
||||
);
|
||||
|
||||
Blockly['Arduino']['variables_get_number'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_get_boolean'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_get_string'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_get_colour'] = getVariableFunction;
|
||||
Blockly['Arduino']['variables_set_dynamic'] = setVariableFunction()
|
||||
Blockly['Arduino']['variables_get_dynamic'] = getVariableFunction;
|
@ -12,25 +12,10 @@ import BlocklyComponent from '../BlocklyComponent';
|
||||
|
||||
class Toolbox extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
/**
|
||||
|
||||
const workspace = this.props;
|
||||
console.log()
|
||||
|
||||
this.props.workspace.registerToolboxCategoryCallback('CREATE_TYPED_VARIABLE', this.createFlyout);
|
||||
|
||||
const typedVarModal = new TypedVariableModal(workspace, 'callbackName', [["PENGUIN", "Penguin"], ["GIRAFFE", "Giraffe"]]);
|
||||
typedVarModal.init();
|
||||
*/
|
||||
console.log(this.props)
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
console.log(this.props)
|
||||
this.props.workspace.registerToolboxCategoryCallback('CREATE_TYPED_VARIABLE', this.createFlyout);
|
||||
|
||||
const typedVarModal = new TypedVariableModal(this.props.workspace, 'callbackName', [['char', 'SHORT_NUMBER'], ['int', 'NUMBER'], ['long', 'DECIMAL'], ['String','TEXT'], ['char', 'CHARACTER'], ['boolean', 'BOOLEAN'], [ 'void' , 'NULL'], ['undefined', 'UNDEF']]);
|
||||
const typedVarModal = new TypedVariableModal(this.props.workspace, 'callbackName', [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']]);
|
||||
typedVarModal.init();
|
||||
}
|
||||
|
||||
@ -337,9 +322,7 @@ class Toolbox extends React.Component {
|
||||
</Block>
|
||||
<Block type="io_notone"></Block>
|
||||
</Category>
|
||||
<Category name="Colours" custom="CREATE_TYPED_VARIABLE"></Category>
|
||||
<Category name="Variablen" colour={getColour().variables} custom="CREATE_TYPED_VARIABLE">
|
||||
</Category>`;
|
||||
<Category name="Variablen" colour={getColour().variables} custom="CREATE_TYPED_VARIABLE"></Category>;
|
||||
<sep></sep>
|
||||
<Category name="Input/Output" colour={getColour().io}>
|
||||
<Block type="io_digitalwrite"></Block>
|
||||
|
Loading…
x
Reference in New Issue
Block a user