Hi,Is it possible to add an item to the context menu (shows up when you right click on a block) and clicking that item would launch a popup window? I want to be able to accomplish this without touching the core blockly library. My goal is to then alter the block after the user exits the popup.
--
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.
var option;
var option = {};
Uncaught TypeError: Cannot set property 'enabled' of undefined
Also not seeing that option show up in the context menu. I did make a small fix to option.enabled = true;
On Friday, February 16, 2018 at 11:24:26 AM UTC-7, Rick J wrote:Andrew,I am relatively new to JS but here was my jab at it. Do you see something that may be wrong in my implementation? I am not seeing any statements logged.Blockly.js code fragmentBlockly.Blocks['create_function'] = {
/**
* Context Menu item to call create function popup
* @param {!Array} options List of menu options to add to.
* @this Blockly.Block
*/
customContextMenu: function(options) {
console.log(options);
var option;
option.enabled = {enabled: true};
option.text = 'Create Function';
option.callback = popupFunction();
options.push(option);
console.log(options);
},
};
function popupFunction() {
console.log('create function clicked!');
};toolbox.js fragment<category name="Functions" colour="200" >
<block type="create_function"></block>
</category>
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@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.
var originalBlocklyContextMenuPopulate = Blockly.ContextMenu.populate_; Blockly.ContextMenu.populate_ = function(options, rtl) { var menu = originalBlocklyContextMenuPopulate(options, rtl); // Modify to your needs. return menu; } |
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+unsubscribe@googlegroups.com.