mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Trivial number/text/colour blocks should inherit parent's tooltip.
This commit is contained in:
@@ -51,9 +51,15 @@ Blockly.Blocks['colour_picker'] = {
|
||||
],
|
||||
"output": "Colour",
|
||||
"colour": Blockly.Blocks.colour.HUE,
|
||||
"tooltip": Blockly.Msg.COLOUR_PICKER_TOOLTIP,
|
||||
"helpUrl": Blockly.Msg.COLOUR_PICKER_HELPURL
|
||||
});
|
||||
// Assign 'this' to a variable for use in the tooltip closure below.
|
||||
var thisBlock = this;
|
||||
// Colour block is trivial. Use tooltip of parent block if it exists.
|
||||
this.setTooltip(function() {
|
||||
var parent = thisBlock.getParent();
|
||||
return (parent && parent.tooltip) || Blockly.Msg.COLOUR_PICKER_TOOLTIP;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +46,13 @@ Blockly.Blocks['math_number'] = {
|
||||
.appendField(new Blockly.FieldTextInput('0',
|
||||
Blockly.FieldTextInput.numberValidator), 'NUM');
|
||||
this.setOutput(true, 'Number');
|
||||
this.setTooltip(Blockly.Msg.MATH_NUMBER_TOOLTIP);
|
||||
// Assign 'this' to a variable for use in the tooltip closure below.
|
||||
var thisBlock = this;
|
||||
// Number block is trivial. Use tooltip of parent block if it exists.
|
||||
this.setTooltip(function() {
|
||||
var parent = thisBlock.getParent();
|
||||
return (parent && parent.tooltip) || Blockly.Msg.MATH_NUMBER_TOOLTIP;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -47,7 +47,13 @@ Blockly.Blocks['text'] = {
|
||||
.appendField(new Blockly.FieldTextInput(''), 'TEXT')
|
||||
.appendField(this.newQuote_(false));
|
||||
this.setOutput(true, 'String');
|
||||
this.setTooltip(Blockly.Msg.TEXT_TEXT_TOOLTIP);
|
||||
// Assign 'this' to a variable for use in the tooltip closure below.
|
||||
var thisBlock = this;
|
||||
// Text block is trivial. Use tooltip of parent block if it exists.
|
||||
this.setTooltip(function() {
|
||||
var parent = thisBlock.getParent();
|
||||
return (parent && parent.tooltip) || Blockly.Msg.TEXT_TEXT_TOOLTIP;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Create an image of an open or closed quote.
|
||||
|
||||
@@ -99,7 +99,7 @@ Blockly.Tooltip.RADIUS_OK = 10;
|
||||
/**
|
||||
* Delay before tooltip appears.
|
||||
*/
|
||||
Blockly.Tooltip.HOVER_MS = 1000;
|
||||
Blockly.Tooltip.HOVER_MS = 750;
|
||||
|
||||
/**
|
||||
* Horizontal padding between tooltip and screen edge.
|
||||
@@ -236,7 +236,7 @@ Blockly.Tooltip.show_ = function() {
|
||||
goog.dom.removeChildren(/** @type {!Element} */ (Blockly.Tooltip.DIV));
|
||||
// Get the new text.
|
||||
var tip = Blockly.Tooltip.element_.tooltip;
|
||||
if (goog.isFunction(tip)) {
|
||||
while (goog.isFunction(tip)) {
|
||||
tip = tip();
|
||||
}
|
||||
tip = Blockly.Tooltip.wrap_(tip, Blockly.Tooltip.LIMIT);
|
||||
|
||||
Reference in New Issue
Block a user