Enhance the existing block of logic_compare

147 views
Skip to first unread message

Kalpesh Rathod

unread,
Jul 19, 2016, 3:31:54 PM7/19/16
to Blockly
Hi,

Blockly provided default "logic_compare" block with Six operator.. 

I want to add "Contain" as operator inside it and i modified below code . (In Red color)

But contain option is not at all reflecting in block. its very simple but struggling. I refreshed browser cache as well

Blockly.Blocks['logic_compare'] = {
  /**
   * Block for comparison operator.
   * @this Blockly.Block
   */
  init: function() {
      var rtlOperators = [
          ['<>', 'NOTEQ'],
      ['=', 'EQ'],
      ['\u2260', 'NEQ'],
      ['>', 'LT'],
      ['\u2265', 'LTE'],
      ['<', 'GT'],
      ['\u2264', 'GTE'],
      ['Contain', 'CON']
    ];
      var ltrOperators = [
      ['<>', 'NOTEQ'],
      ['=', 'EQ'],
      ['\u2260', 'NEQ'],
      ['<', 'LT'],
      ['\u2264', 'LTE'],
      ['>', 'GT'],
      ['\u2265', 'GTE'],
      ['Contain', 'CON']
    ];
    var OPERATORS = this.RTL ? rtlOperators : ltrOperators;
    this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL);
    this.setColour(Blockly.Blocks.logic.HUE);
    this.setOutput(true, 'Boolean');
    this.appendValueInput('A');
    this.appendValueInput('B')
        .appendField(new Blockly.FieldDropdown(OPERATORS), 'OP');
    this.setInputsInline(true);
    // Assign 'this' to a variable for use in the tooltip closure below.
    var thisBlock = this;
    this.setTooltip(function() {
      var op = thisBlock.getFieldValue('OP');
      var TOOLTIPS = {
        'EQ': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ,
        'NEQ': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ,
        'LT': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT,
        'LTE': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE,
        'GT': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT,
        'GTE': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE,
        'Contain': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE
      };
      return TOOLTIPS[op];
    });
    this.prevBlocks_ = [null, null];
  },


Neil Fraser

unread,
Jul 19, 2016, 3:34:01 PM7/19/16
to blo...@googlegroups.com

Try /tests/playground.html
Do your changes show up there?

Send (awkwardly) from an Android phone.


--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kalpesh Rathod

unread,
Jul 19, 2016, 3:47:55 PM7/19/16
to Blockly
No

Kalpesh Rathod

unread,
Jul 19, 2016, 4:04:36 PM7/19/16
to Blockly
After playing couple of hour....i removed that category from tool box and added back  and it display the option in dropdown. clearing browser cache does not help

Thanks
Kalpesh


On Tuesday, July 19, 2016 at 12:31:54 PM UTC-7, Kalpesh Rathod wrote:
Reply all
Reply to author
Forward
0 new messages