1

I have small problem about blockly.

I need to call some event (for example alert('hello world') ) when someone blurs text input.

I used Blockly.addChangeListener, but this function is not called when someone create blur event on text input.

Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
  • Welcome to SO. Please visit the [help] to see how to ask questions at SO – mplungjan Jul 27 '15 at 12:34
  • I do not see a blur event here https://developers.google.com/blockly/custom-blocks/defining-blocks - perhaps you can create one like here: https://code.google.com/p/blockly/source/browse/trunk/core/blockly.js?r=1637#718 – mplungjan Jul 27 '15 at 12:38
  • Yes I know that this function don´t exist. But i have to detect if someone end of writing for example cath if someone blur input. I need to create function for autosave, but save only when someone doing but not typeing. – Michal Sládeček Jul 27 '15 at 12:44
  • Perhaps save after an interval as most editors do – mplungjan Jul 27 '15 at 12:46
  • Yes one option is that call save event every x scond, but i don't know if is the beast choise. – Michal Sládeček Jul 27 '15 at 12:51
  • It is likely the ONLY choice if you do not make a blur listener – mplungjan Jul 27 '15 at 12:52

1 Answers1

1

You can create an onchange event for your input Block. Something like this:

onchange: function(event) {
  var text = Blockly.Javascript.valueToCode(this, 'textBox', Blockly.C.ORDER_ATOMIC);
  if (text == "") {
    alert("Hello world");
  } else {
    alert(text);
  }
}

where this makes reference to your input Block and textBox makes reference to the name that you have set to yours input box.

Francisco Romero
  • 12,787
  • 22
  • 92
  • 167