Will try to explain what happens:
node.originalKeyDownHandler = Blockly.onKeyDown_;
Blockly.onKeyDown_ = function(e) {
node.originalKeyDownHandler(e);
debugger;
e.stopPropagation();
}Blockly.onKeyDown_ = node.originalKeyDownHandler;--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
if (Blockly.blocklyEditorVisible === undefined) {
Blockly.originalKeyDownHandler = Blockly.onKeyDown_;
Blockly.onKeyDown_ = function(e) {
// Stop the events from propagating up the DOM tree
if (Blockly.blocklyEditorVisible) {
Blockly.originalKeyDownHandler(e);
e.stopPropagation();
}
}
}
Blockly.blocklyEditorVisible = true;So the custom onkeydown handler is setup ONCE , and from then on this handler will be used all the time by Blockly (i.e. I don't remove the handler anymore afterwards).
Blockly.blocklyEditorVisible = false;