mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Fix mutator/warning/comment icons to highlight on mouse over only if they are usable.
This commit is contained in:
@@ -945,11 +945,9 @@ Blockly.BlockSvg.prototype.setMovable = function(movable) {
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.setEditable = function(editable) {
|
||||
Blockly.BlockSvg.superClass_.setEditable.call(this, editable);
|
||||
if (this.rendered) {
|
||||
var icons = this.getIcons();
|
||||
for (var i = 0; i < icons.length; i++) {
|
||||
icons[i].updateEditable();
|
||||
}
|
||||
var icons = this.getIcons();
|
||||
for (var i = 0; i < icons.length; i++) {
|
||||
icons[i].updateEditable();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
11
core/icon.js
11
core/icon.js
@@ -78,6 +78,10 @@ Blockly.Icon.prototype.createIcon = function() {
|
||||
*/
|
||||
this.iconGroup_ = Blockly.createSvgElement('g',
|
||||
{'class': 'blocklyIconGroup'}, null);
|
||||
if (this.block_.isInFlyout) {
|
||||
Blockly.addClass_(/** @type {!Element} */ (this.iconGroup_),
|
||||
'blocklyIconGroupReadonly');
|
||||
}
|
||||
this.drawIcon_(this.iconGroup_);
|
||||
|
||||
this.block_.getSvgRoot().appendChild(this.iconGroup_);
|
||||
@@ -101,13 +105,6 @@ Blockly.Icon.prototype.dispose = function() {
|
||||
* Add or remove the UI indicating if this icon may be clicked or not.
|
||||
*/
|
||||
Blockly.Icon.prototype.updateEditable = function() {
|
||||
if (this.block_.isInFlyout || !this.block_.isEditable()) {
|
||||
Blockly.addClass_(/** @type {!Element} */ (this.iconGroup_),
|
||||
'blocklyIconGroupReadonly');
|
||||
} else {
|
||||
Blockly.removeClass_(/** @type {!Element} */ (this.iconGroup_),
|
||||
'blocklyIconGroupReadonly');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -139,17 +139,23 @@ Blockly.Mutator.prototype.createEditor_ = function() {
|
||||
* Add or remove the UI indicating if this icon may be clicked or not.
|
||||
*/
|
||||
Blockly.Mutator.prototype.updateEditable = function() {
|
||||
if (this.block_.isEditable()) {
|
||||
// Default behaviour for an icon.
|
||||
Blockly.Icon.prototype.updateEditable.call(this);
|
||||
} else {
|
||||
// Close any mutator bubble. Icon is not clickable.
|
||||
this.setVisible(false);
|
||||
if (this.iconGroup_) {
|
||||
Blockly.addClass_(/** @type {!Element} */ (this.iconGroup_),
|
||||
'blocklyIconGroupReadonly');
|
||||
if (!this.block_.isInFlyout) {
|
||||
if (this.block_.isEditable()) {
|
||||
if (this.iconGroup_) {
|
||||
Blockly.removeClass_(/** @type {!Element} */ (this.iconGroup_),
|
||||
'blocklyIconGroupReadonly');
|
||||
}
|
||||
} else {
|
||||
// Close any mutator bubble. Icon is not clickable.
|
||||
this.setVisible(false);
|
||||
if (this.iconGroup_) {
|
||||
Blockly.addClass_(/** @type {!Element} */ (this.iconGroup_),
|
||||
'blocklyIconGroupReadonly');
|
||||
}
|
||||
}
|
||||
}
|
||||
// Default behaviour for an icon.
|
||||
Blockly.Icon.prototype.updateEditable.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user