mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
Fix #1619. buildTooltipWithFieldValue() => buildTooltipWithFieldText() The "value" of FieldVariables was the variable id. However, we usually want the field text for the human visible tooltip. Refactoring and renaming buildTooltipWithFieldValue to use the field text.
This commit is contained in:
committed by
GitHub
parent
4092a644d5
commit
f45c6faf05
@@ -280,11 +280,11 @@ Blockly.Extensions.registerMixin('contextMenu_newGetVariableBlock',
|
||||
Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN);
|
||||
|
||||
Blockly.Extensions.register('controls_for_tooltip',
|
||||
Blockly.Extensions.buildTooltipWithFieldValue(
|
||||
Blockly.Extensions.buildTooltipWithFieldText(
|
||||
'%{BKY_CONTROLS_FOR_TOOLTIP}', 'VAR'));
|
||||
|
||||
Blockly.Extensions.register('controls_forEach_tooltip',
|
||||
Blockly.Extensions.buildTooltipWithFieldValue(
|
||||
Blockly.Extensions.buildTooltipWithFieldText(
|
||||
'%{BKY_CONTROLS_FOREACH_TOOLTIP}', 'VAR'));
|
||||
|
||||
/**
|
||||
|
||||
@@ -492,20 +492,9 @@ Blockly.Extensions.registerMutator('math_is_divisibleby_mutator',
|
||||
Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN,
|
||||
Blockly.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION);
|
||||
|
||||
/**
|
||||
* Update the tooltip of 'math_change' block to reference the variable.
|
||||
* @this Blockly.Block
|
||||
* @package
|
||||
*/
|
||||
Blockly.Constants.Math.CHANGE_TOOLTIP_EXTENSION = function() {
|
||||
this.setTooltip(function() {
|
||||
return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace('%1',
|
||||
this.getFieldValue('VAR'));
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
// Update the tooltip of 'math_change' block to reference the variable.
|
||||
Blockly.Extensions.register('math_change_tooltip',
|
||||
Blockly.Extensions.buildTooltipWithFieldValue(
|
||||
Blockly.Extensions.buildTooltipWithFieldText(
|
||||
'%{BKY_MATH_CHANGE_TOOLTIP}', 'VAR'));
|
||||
|
||||
/**
|
||||
|
||||
@@ -773,17 +773,10 @@ Blockly.Constants.Text.TEXT_JOIN_EXTENSION = function() {
|
||||
this.setMutator(new Blockly.Mutator(['text_create_join_item']));
|
||||
};
|
||||
|
||||
Blockly.Constants.Text.TEXT_APPEND_TOOLTIP_EXTENSION = function() {
|
||||
// Assign 'this' to a variable for use in the tooltip closure below.
|
||||
var thisBlock = this;
|
||||
this.setTooltip(function() {
|
||||
if (Blockly.Msg.TEXT_APPEND_TOOLTIP) {
|
||||
return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace('%1',
|
||||
thisBlock.getFieldValue('VAR'));
|
||||
}
|
||||
return '';
|
||||
});
|
||||
};
|
||||
// Update the tooltip of 'text_append' block to reference the variable.
|
||||
Blockly.Extensions.register('text_append_tooltip',
|
||||
Blockly.Extensions.buildTooltipWithFieldText(
|
||||
'%{BKY_TEXT_APPEND_TOOLTIP}', 'VAR'));
|
||||
|
||||
Blockly.Constants.Text.TEXT_INDEXOF_TOOLTIP_EXTENSION = function() {
|
||||
// Assign 'this' to a variable for use in the tooltip closure below.
|
||||
@@ -889,9 +882,6 @@ Blockly.Extensions.register('text_indexOf_tooltip',
|
||||
Blockly.Extensions.register('text_quotes',
|
||||
Blockly.Constants.Text.TEXT_QUOTES_EXTENSION);
|
||||
|
||||
Blockly.Extensions.register('text_append_tooltip',
|
||||
Blockly.Constants.Text.TEXT_APPEND_TOOLTIP_EXTENSION);
|
||||
|
||||
Blockly.Extensions.registerMutator('text_join_mutator',
|
||||
Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN,
|
||||
Blockly.Constants.Text.TEXT_JOIN_EXTENSION);
|
||||
|
||||
Reference in New Issue
Block a user