Problem statement
Over the years, the extended App Inventor team has worked on a number of features that have modified Blockly core to add icons. It would be nice if we could have an API for registering new icons with the block so that we can keep the core clean(er).
Expected Behavior
The ability to do something like:
AI.Blockly.MyIconConstructor = function(block) { ... }
goog.inherits(AIBlockly.MyIconConstructor, Blockly.Icon);
// [snip] cf. Blockly.Mutator or Blockly.Warning
Blockly.Block.registerIcon('myicon', AI.Blockly.MyIconConstructor);
var block = Blockly.mainWorkspace.newBlock('controls_if');
// Visibility option 1
block.showIcon('myicon');
block.hideIcon('myicon');
// Visibility option 2
block.setIconVisible('myicon', true);
Actual Behavior
One needs to modify multiple parts of core, such as block.js, block_render_svg.js, etc. to make this work correctly. This includes modifying functions like getIcons() and dispose() to handle the additional icons.
Operating System and Browser
Affects all browsers
Additional Information
We can provide pointers to examples over the years where we have done this if necessary to better understand the problem.
Problem statement
Over the years, the extended App Inventor team has worked on a number of features that have modified Blockly core to add icons. It would be nice if we could have an API for registering new icons with the block so that we can keep the core clean(er).
Expected Behavior
The ability to do something like:
Actual Behavior
One needs to modify multiple parts of core, such as block.js, block_render_svg.js, etc. to make this work correctly. This includes modifying functions like getIcons() and dispose() to handle the additional icons.
Operating System and Browser
Affects all browsers
Additional Information
We can provide pointers to examples over the years where we have done this if necessary to better understand the problem.