Popup on input value check

69 views
Skip to first unread message

Arbaz Sheikh

unread,
Feb 2, 2021, 1:59:12 AM2/2/21
to Blockly
Hello,

I used the check function on Input Value so that only a block with a particular output gets attached to it. It is working properly.
Now i want to show a popup if the wrong blocks gets attached to Input value showing some message. How can i achieve this? Can anyone help me with this
I am not able to find any event getting triggered for block check

Beka Westberg

unread,
Feb 2, 2021, 6:44:25 PM2/2/21
to blo...@googlegroups.com
Hello,

Could you expand a bit more about exactly what you're looking for? For example, do you want the user to connect the block, then have the block automatically disconnect, and then show the popup? Or do you want to detect when a user is trying to connect a block, and then show the popup?

If you're looking for the former, it's probably easier to not use the connection checking system hehe. I'd recommend that instead you use an event listener that checks for the move event. The process would basically look like this:
1) The "bad" block will connect to your input
2) This will fire a move event.
3) Your listener will then look at the connected blocks, and see if they're compatible (using your own system to track compatibility).
4) If they're not, you can disconnect them using connection.disconnect for the relevant connection, and display your popup.

If you're looking for the latter, I'm not sure if that's possible with the current version of Blockly :/ The main issue will be detecting when the user is trying to connect a block to the bad input. You might be able to fork Blockly and add some logic to the BlockDragger (or one of the related classes) but I'm really not sure :/

But then again, it might not be worth the hassle hehe. Personally I think that not allowing bad blocks to connect is really intuitive and useful to the user! And it makes sure that their code is never in a broken state (even momentarily =)

I hope that helps! If there's anything else you're curious about 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/2e3421ea-2014-4f15-90da-a935081ffbe1n%40googlegroups.com.

Arbaz Sheikh

unread,
Feb 4, 2021, 2:37:57 AM2/4/21
to Blockly
Thank you.
I was just willing to know if we could get this functionality done with blockly connection checking system. Its ok I'll just go ahead with event listener process.

Reply all
Reply to author
Forward
0 new messages