Commit a5ea93a1 authored by Neil Fraser's avatar Neil Fraser

Allow comments in flyouts.

parent 26828d6c
......@@ -40,8 +40,6 @@ Blockly.Blocks['procedures_defnoreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
var nameField = new Blockly.FieldTextInput(
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,
Blockly.Procedures.rename);
......@@ -51,7 +49,10 @@ Blockly.Blocks['procedures_defnoreturn'] = {
.appendField(nameField, 'NAME')
.appendField('', 'PARAMS');
this.setMutator(new Blockly.Mutator(['procedures_mutatorarg']));
this.setCommentText(''); // TODO: Add 'Describe this function...'
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
this.arguments_ = [];
this.setStatements_(true);
this.statementConnection_ = null;
......@@ -343,8 +344,6 @@ Blockly.Blocks['procedures_defreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
var nameField = new Blockly.FieldTextInput(
Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE,
Blockly.Procedures.rename);
......@@ -357,7 +356,10 @@ Blockly.Blocks['procedures_defreturn'] = {
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);
this.setMutator(new Blockly.Mutator(['procedures_mutatorarg']));
this.setCommentText(''); // TODO: Add 'Describe this function...'
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);
this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);
this.arguments_ = [];
this.setStatements_(true);
this.statementConnection_ = null;
......@@ -393,13 +395,13 @@ Blockly.Blocks['procedures_mutatorcontainer'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);
this.appendStatementInput('STACK');
this.appendDummyInput('STATEMENT_INPUT')
.appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS)
.appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
this.contextMenu = false;
}
......@@ -411,12 +413,12 @@ Blockly.Blocks['procedures_mutatorarg'] = {
* @this Blockly.Block
*/
init: function() {
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE)
.appendField(new Blockly.FieldTextInput('x', this.validator_), 'NAME');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);
this.contextMenu = false;
},
......@@ -441,14 +443,14 @@ Blockly.Blocks['procedures_callnoreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput('TOPROW')
.appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL)
.appendField('', 'NAME');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
// Tooltip is set in domToMutation.
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.arguments_ = [];
this.quarkConnections_ = {};
this.quarkArguments_ = null;
......@@ -670,13 +672,13 @@ Blockly.Blocks['procedures_callreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendDummyInput('TOPROW')
.appendField(Blockly.Msg.PROCEDURES_CALLRETURN_CALL)
.appendField('', 'NAME');
this.setOutput(true);
this.setColour(Blockly.Blocks.procedures.HUE);
// Tooltip is set in domToMutation.
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.arguments_ = [];
this.quarkConnections_ = {};
this.quarkArguments_ = null;
......@@ -698,8 +700,6 @@ Blockly.Blocks['procedures_ifreturn'] = {
* @this Blockly.Block
*/
init: function() {
this.setHelpUrl('http://c2.com/cgi/wiki?GuardClause');
this.setColour(Blockly.Blocks.procedures.HUE);
this.appendValueInput('CONDITION')
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);
......@@ -708,7 +708,9 @@ Blockly.Blocks['procedures_ifreturn'] = {
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);
this.setHelpUrl('http://c2.com/cgi/wiki?GuardClause'); // TODO: Extract.
this.hasReturnValue_ = true;
},
/**
......
......@@ -46,8 +46,6 @@ goog.require('goog.math.Coordinate');
* @constructor
*/
Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
Blockly.BlockSvg.superClass_.constructor.call(this,
workspace, prototypeName, opt_id);
// Create core elements for the block.
/** @type {SVGElement} */
this.svgGroup_ = Blockly.createSvgElement('g', {}, null);
......@@ -63,6 +61,8 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) {
{'class': 'blocklyPathLight'}, this.svgGroup_);
this.svgPath_.tooltip = this;
Blockly.Tooltip.bindMouseEvents(this.svgPath_);
Blockly.BlockSvg.superClass_.constructor.call(this,
workspace, prototypeName, opt_id);
};
goog.inherits(Blockly.BlockSvg, Blockly.Block);
......@@ -98,8 +98,9 @@ Blockly.BlockSvg.prototype.initSvg = function() {
for (var i = 0, input; input = this.inputList[i]; i++) {
input.init();
}
if (this.mutator) {
this.mutator.createIcon();
var icons = this.getIcons();
for (var i = 0; i < icons.length; i++) {
icons[i].createIcon();
}
this.updateColour();
this.updateMovable();
......@@ -439,6 +440,7 @@ Blockly.BlockSvg.prototype.tab = function(start, forward) {
*/
Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
if (this.isInFlyout) {
e.stopPropagation();
return;
}
this.workspace.markFocused();
......@@ -1505,10 +1507,8 @@ Blockly.BlockSvg.prototype.setMutator = function(mutator) {
if (mutator) {
mutator.block_ = this;
this.mutator = mutator;
if (this.rendered) {
mutator.createIcon();
}
}
};
/**
......
......@@ -401,10 +401,6 @@ Blockly.Flyout.prototype.show = function(xmlList) {
// prevent the closure of the flyout if the user right-clicks on such a
// block.
child.isInFlyout = true;
// There is no good way to handle comment bubbles inside the flyout.
// Blocks shouldn't come with predefined comments, but someone will
// try this, I'm sure. Kill the comment.
child.setCommentText(null);
}
block.render();
var root = block.getSvgRoot();
......
......@@ -702,7 +702,7 @@ Blockly.WorkspaceSvg.prototype.cleanUp_ = function() {
* @private
*/
Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) {
if (this.options.readOnly) {
if (this.options.readOnly || this.isFlyout) {
return;
}
var menuOptions = [];
......
......@@ -386,7 +386,7 @@ Blockly.Xml.domToBlockHeadless_ = function(workspace, xmlBlock) {
case 'comment':
block.setCommentText(xmlChild.textContent);
var visible = xmlChild.getAttribute('pinned');
if (visible) {
if (visible && !block.isInFlyout) {
// Give the renderer a millisecond to render and position the block
// before positioning the comment bubble.
setTimeout(function() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment