Start getting helpurl and tooltip in

This commit is contained in:
Rachel Fenichel
2016-11-11 15:50:53 -08:00
parent 1d55e28610
commit 4871ff9fda
4 changed files with 28 additions and 3 deletions

View File

@@ -52,6 +52,12 @@ Blockly.Blocks['factory_base'] = {
});
this.appendDummyInput()
.appendField(dropdown, 'CONNECTIONS');
this.appendValueInput('TOOLTIP')
.setCheck('String')
.appendField('tooltip');
this.appendValueInput('HELPURL')
.setCheck('String')
.appendField('help url');
this.appendValueInput('COLOUR')
.setCheck('Colour')
.appendField('colour');

View File

@@ -66,6 +66,12 @@ BlockFactory.oldDir = null;
*/
BlockFactory.STARTER_BLOCK_XML_TEXT = '<xml><block type="factory_base" ' +
'deletable="false" movable="false">' +
'<value name="TOOLTIP">' +
'<block type="text" deletable="false" movable="false">' +
'<field name="TEXT"></field></block></value>' +
'<value name="HELPURL">' +
'<block type="text" deletable="false" movable="false">' +
'<field name="TEXT"></field></block></value>' +
'<value name="COLOUR">' +
'<block type="colour_hue">' +
'<mutation colour="#5b67a5"></mutation>' +

View File

@@ -250,8 +250,20 @@ FactoryUtils.formatJson_ = function(blockType, rootBlock) {
var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
JS.colour = hue;
}
JS.tooltip = '';
JS.helpUrl = 'http://www.example.com/';
// Tooltip.
var tooltipBlock = rootBlock.getInputTargetBlock('TOOLTIP');
if (tooltipBlock && !tooltipBlock.disabled) {
JS.tooltip = tooltipBlock.getFieldValue('TEXT');
} else {
JS.tooltip = '';
}
// Help URL.
var helpUrlBlock = rootBlock.getInputTargetBlock('HELPURL');
if (helpUrlBlock && !helpUrlBlock.disabled) {
JS.helpUrl = helpUrlBlock.getFieldValue('TEXT');
} else {
JS.helpUrl = 'http://www.example.com/';
}
return JSON.stringify(JS, null, ' ');
};
@@ -334,6 +346,7 @@ FactoryUtils.formatJavaScript_ = function(blockType, rootBlock, workspace) {
code.push(' this.setColour(' + hue + ');');
}
}
// TODO: Rachel: tooltip and helpurl
code.push(" this.setTooltip('');");
code.push(" this.setHelpUrl('http://www.example.com/');");
code.push(' }');

View File

@@ -6,7 +6,7 @@
<title>Blockly Demo:</title>
<link rel="stylesheet" href="style.css">
<script src="/storage.js"></script>
<script src="../../blockly_compressed.js"></script>
<script src="../../blockly_uncompressed.js"></script>
<script src="../../blocks_compressed.js"></script>
<script src="../../javascript_compressed.js"></script>
<script src="../../python_compressed.js"></script>