-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Is your feature request related to a problem? Please describe.
In App Inventor, we have an option to arrange the parameters of definition blocks (events, procedures) either horizontally or vertically. Because this changes the block, we want to leverage Blockly.Events.Change to record the operation in the undo/redo stack. However, there is no way to support new elements in the Change event without modifying core.
Describe the solution you'd like
I propose the following API:
Blockly.Events.Change.elementRegistry_ = {};
Blockly.Events.Change.registerElement = function(element, callback) {
Blockly.Events.Change.elementRegistry_[element] = callback;
};so that we could then call in our code:
Blockly.Events.Change.registerElement('parameter_orientation', function(event) {
// handle event here
});The whole of the switch in Change.run could be rewritten using this API, or we could just have it as a lookup in the default clause. I have no preference either way, but the former might be useful if people want to further tweak the behavior of Blockly core behavior.
Describe alternatives you've considered
Alternatively, we can monkeypatch the run method, but that doesn't really help much.
Additional context