block.setDeletable (false); block.setEditable (false);

592 views
Skip to first unread message

Julien LYOTARD

unread,
Jul 23, 2016, 5:15:01 AM7/23/16
to Blockly
Hello,
I do not use the properties:
block.setDeletable (false);
block.setEditable (false);

I tried this.setEditable (false); in a block that I create and it does not work.

Could do we define its properties in the XML like this:
<Block type = "point" style = "readonly: true">

thank you for your reply

Julien LYOTARD

unread,
Jul 23, 2016, 5:03:19 PM7/23/16
to Blockly
The following code does not work :

Blockly.Blocks['math_number'] = {
  /**
   * Block for numeric value.
   * @this Blockly.Block
   */
  init: function() {
    this.setHelpUrl(Blockly.Msg.MATH_NUMBER_HELPURL);
    this.setColour(Blockly.Blocks.math.HUE);
    this.appendDummyInput()
        .appendField(new Blockly.FieldNumber('0'), 'NUM');
this.setEditable (false);
    this.setOutput(true, 'Number');
    // Assign 'this' to a variable for use in the tooltip closure below.
    var thisBlock = this;
    // Number block is trivial.  Use tooltip of parent block if it exists.
this.setTooltip(function() {
      var parent = thisBlock.getParent();
      return (parent && parent.getInputsInline() && parent.tooltip) ||
          Blockly.Msg.MATH_NUMBER_TOOLTIP;
    });
  }
};

By this.setDeletable (false); works but if I add item to set before the block is again deletable.

Is there a way to set the properties with the xml ?

Otherwise blockly is really great !!

Erik Pasternak

unread,
Jul 25, 2016, 11:46:18 AM7/25/16
to Blockly
You can set them in xml using movable="true|false", deletable="true|false", or editable="true|false". It looks like editable broke recently but we'll get it fixed soon.

<block type="math_number" deletable="false" movable="false">

Julien LYOTARD

unread,
Jul 26, 2016, 3:59:55 AM7/26/16
to Blockly
Thank you for your reply. If you can do a little wave when the movable option will be used would be perfect.

Erik Pasternak

unread,
Jul 26, 2016, 11:16:58 AM7/26/16
to Blockly
Quick update, it looks like editable was already fixed we just haven't rebuilt the playground yet. You should be fine to use all three in your own code if you've recently pulled.

On Tue, Jul 26, 2016 at 12:59 AM, Julien LYOTARD <gro...@gmail.com> wrote:
Thank you for your reply. If you can do a little wave when the movable option will be used would be perfect.

--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/SOSv8v2e2tA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Erik Pasternak | Master of the House | epas...@google.com     
Reply all
Reply to author
Forward
0 new messages