mirror of
https://github.com/google/blockly.git
synced 2026-01-18 14:27:12 +01:00
Merge pull request #2084 from rachel-fenichel/bugfix/2030_remainder
Fix setting tooltips in field init for fields
This commit is contained in:
@@ -52,6 +52,7 @@ Blockly.FieldImage = function(src, width, height, opt_alt, opt_onClick) {
|
||||
this.size_ = new goog.math.Size(this.width_,
|
||||
this.height_ + 2 * Blockly.BlockSvg.INLINE_PADDING_Y);
|
||||
this.text_ = opt_alt || '';
|
||||
this.tooltip_ = '';
|
||||
this.setValue(src);
|
||||
|
||||
if (typeof opt_onClick == 'function') {
|
||||
@@ -108,8 +109,12 @@ Blockly.FieldImage.prototype.init = function() {
|
||||
this.setValue(this.src_);
|
||||
this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_);
|
||||
|
||||
// Configure the field to be transparent with respect to tooltips.
|
||||
this.setTooltip(this.sourceBlock_);
|
||||
if (this.tooltip_) {
|
||||
this.imageElement_.tooltip = this.tooltip_;
|
||||
} else {
|
||||
// Configure the field to be transparent with respect to tooltips.
|
||||
this.setTooltip(this.sourceBlock_);
|
||||
}
|
||||
Blockly.Tooltip.bindMouseEvents(this.imageElement_);
|
||||
|
||||
this.maybeAddClickHandler_();
|
||||
@@ -145,7 +150,10 @@ Blockly.FieldImage.prototype.maybeAddClickHandler_ = function() {
|
||||
* link to for its tooltip.
|
||||
*/
|
||||
Blockly.FieldImage.prototype.setTooltip = function(newTip) {
|
||||
this.imageElement_.tooltip = newTip;
|
||||
this.tooltip_ = newTip;
|
||||
if (this.imageElement_) {
|
||||
this.imageElement_.tooltip = newTip;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,6 +44,7 @@ Blockly.FieldLabel = function(text, opt_class) {
|
||||
this.size_ = new goog.math.Size(0, 17.5);
|
||||
this.class_ = opt_class;
|
||||
this.setValue(text);
|
||||
this.tooltip_ = '';
|
||||
};
|
||||
goog.inherits(Blockly.FieldLabel, Blockly.Field);
|
||||
|
||||
@@ -84,8 +85,12 @@ Blockly.FieldLabel.prototype.init = function() {
|
||||
}
|
||||
this.sourceBlock_.getSvgRoot().appendChild(this.textElement_);
|
||||
|
||||
// Configure the field to be transparent with respect to tooltips.
|
||||
this.textElement_.tooltip = this.sourceBlock_;
|
||||
if (this.tooltip_) {
|
||||
this.textElement_.tooltip = this.tooltip_;
|
||||
} else {
|
||||
// Configure the field to be transparent with respect to tooltips.
|
||||
this.textElement_.tooltip = this.sourceBlock_;
|
||||
}
|
||||
Blockly.Tooltip.bindMouseEvents(this.textElement_);
|
||||
// Force a render.
|
||||
this.render_();
|
||||
@@ -116,7 +121,10 @@ Blockly.FieldLabel.prototype.getSvgRoot = function() {
|
||||
* link to for its tooltip.
|
||||
*/
|
||||
Blockly.FieldLabel.prototype.setTooltip = function(newTip) {
|
||||
this.textElement_.tooltip = newTip;
|
||||
this.tooltip_ = newTip;
|
||||
if (this.textElement_) {
|
||||
this.textElement_.tooltip = newTip;
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Field.register('field_label', Blockly.FieldLabel);
|
||||
|
||||
Reference in New Issue
Block a user