Identify Double Click On A Blockly

86 views
Skip to first unread message

Rishabh Kankani

unread,
Feb 1, 2024, 12:41:03 AM2/1/24
to Blockly
I want to redirect or do some functions on double click of a blockly and hence i want to identify double click

When I added a event listener to workspace I'm getting event like this
I'm using typescript in angular


Screenshot 2024-02-01 110944.png

Beka Westberg

unread,
Feb 1, 2024, 11:12:37 AM2/1/24
to blo...@googlegroups.com
Hello,

Yes you can use that event to detect double clicks! Here is how they do it in App Inventor:

```js
  if (event instanceof Blockly.Events.Click) {
    if (this.doubleClickPid_) {
      clearTimeout(this.doubleClickPid_);
      this.doubleClickPid_ = undefined;
      if (event.blockId === this.doubleClickBlock_) {
        var block = this.getBlockById(this.doubleClickBlock_);
        // Do actions here!!
        return;
      }
    }
    if (!this.doubleClickPid_) {
      this.doubleClickBlock_ = event.blockId;
      this.doubleClickPid_ = setTimeout(function() {
        this.doubleClickPid_ = undefined;
      }.bind(this), 500);  // windows uses 500ms as the default speed; seems reasonable enough
    }
  }

```

Note that they have their implementation in the `fireChangeListener` method, but you shouldn't need to do this. You can include the above code in a change listener just like your current logging.

I hope that helps! If you have any further questions please reply =)
--Beka

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/88a6457a-24af-4b8f-ba02-b9aa68a73c3dn%40googlegroups.com.

Rishabh Kankani

unread,
Feb 1, 2024, 1:29:01 PM2/1/24
to Blockly
Thanks Beka I already found some solution for this, can u please look into the procedure query thread
Reply all
Reply to author
Forward
0 new messages