Hello friends,
I was planning to use custom tooltip function in my code. It's an angular based app with latest blockly integration via npm. Here is the custom tooltip function that i copied from samples:
initTooltips() {
const customTooltip = function (div, element) {
if (element instanceof Blockly.BlockSvg) {
div.style.backgroundColor = element.getColour();
}
const tip = Blockly.Tooltip.getTooltipOfObject(element);
const text = document.createElement('div');
text.textContent = tip;
const container = document.createElement('div');
container.style.display = 'flex';
if (element.type == 'ShowTableBlock') {
const img = document.createElement('img');
img.setAttribute('src', "ShowTable.gif");
container.appendChild(img);
}
container.appendChild(text);
div.appendChild(container);
};
// Register the function in the Blockly.Tooltip so that Blockly calls it
// when needed.
Blockly.Tooltip.setCustomTooltip(customTooltip);
}
Here is how I am adding it:
createBlocklyWorkspace() {
this.workspace = Blockly.inject('blocklyDiv', this.defaultOptions);
const workspaceSearch = new WorkspaceSearch(this.workspace);
workspaceSearch.init();
workspaceSearch.open();
const backpack = new Backpack(this.workspace);
backpack.init();
this.initTooltips();
}
Somehow the customtooltip function is not getting hit, Any suggestions what I might be missing?