You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The field label and image implementation of setTooltip depends on the svg elements having been created. This doesn't happen until well after the block's init(), which causes a crash if you try to set the tooltip on a field during init().
Expected Behavior
Should be able to configure field tooltips during init()
Actual Behavior
Crashes
Steps to Reproduce
Create a block with the following definition
Blockly.Blocks['test_1'] = {
init: function() {
this.appendDummyInput('in1');
var in1 = this.getInput('in1');
var field = new Blockly.FieldLabel('Test');
field.setTooltip('Test tooltip');
in1.appendField(field);
}
};
Create a new test_1 block.
Stack Traces
field_label.js:119 Uncaught TypeError: Cannot set property 'tooltip' of undefined
at Blockly.FieldLabel.setTooltip (field_label.js:119)
at Blockly.BlockSvg.init (:10:9)
at Blockly.BlockSvg.Blockly.Block (block.js:165)
at new Blockly.BlockSvg (block_svg.js:99)
at Blockly.WorkspaceSvg.newBlock (workspace_svg.js:579)
at :1:44
Replace with error stack trace.
Operating System and Browser
Additional Information
Proposed fix:
in setTooltip
Save the tooltip on the field directly.
If the UI exists, set it on the UI
Otherwise wait until field.init() is called to set the tooltip on the UI.
The text was updated successfully, but these errors were encountered:
Did these tooltip-related functions ever work? The FieldImage one does something very different from the function description; I can't tell if the FieldLabel one works as-is.
Go to the playground. Create a 'not' block. Then enter the following in the console: workspace.topBlocks_[0].inputList[0].fieldRow[0].setTooltip('Hello')
Seems to work.
Problem statement
The field label and image implementation of setTooltip depends on the svg elements having been created. This doesn't happen until well after the block's init(), which causes a crash if you try to set the tooltip on a field during init().
Expected Behavior
Should be able to configure field tooltips during init()
Actual Behavior
Crashes
Steps to Reproduce
Blockly.Blocks['test_1'] = {
init: function() {
this.appendDummyInput('in1');
var in1 = this.getInput('in1');
var field = new Blockly.FieldLabel('Test');
field.setTooltip('Test tooltip');
in1.appendField(field);
}
};
Stack Traces
field_label.js:119 Uncaught TypeError: Cannot set property 'tooltip' of undefined
at Blockly.FieldLabel.setTooltip (field_label.js:119)
at Blockly.BlockSvg.init (:10:9)
at Blockly.BlockSvg.Blockly.Block (block.js:165)
at new Blockly.BlockSvg (block_svg.js:99)
at Blockly.WorkspaceSvg.newBlock (workspace_svg.js:579)
at :1:44
Operating System and Browser
Additional Information
Proposed fix:
in setTooltip
The text was updated successfully, but these errors were encountered: