Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Change block to output on drag

32 views
Skip to first unread message

Joshua Lowe

unread,
Feb 7, 2025, 11:21:11 AMFeb 7
to Blockly
Hi all,

I'm wondering if it's possible to change a block to an output if it's dragged over a value input, and if it's dragged under a next connection of another block, the block has a previous/next connection instead.

Pointers in the right direction, or knowing if this is simply not possible, would be greatly appreciated!

Mark Friedman

unread,
Feb 7, 2025, 1:05:12 PMFeb 7
to blo...@googlegroups.com
Yes!  I call it a chameleon block and you can see an example of this in my presentation (slide 11) at the 2022 Blockly Summit.  You can find my implementation of it here in my implementation of procedure call blocks for my Scheme Blocks project (which I hope to get back to soon-ish).

-Mark


--
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 visit https://groups.google.com/d/msgid/blockly/2cbbe15c-f2aa-4c6a-bee2-a806f6d9a2f9n%40googlegroups.com.

Joshua Lowe

unread,
Feb 7, 2025, 5:09:30 PMFeb 7
to Blockly
Thanks Mark! This is really interesting and super close to what I was looking at achieving.

I'm using the Zelos renderer, so having a previous, next and output connection on the same block looks a little weird. 

My idea was to have no connections at all to begin with, so the block is essentially a square, and then, as you drag the block close to a connection, it would dynamically add previous/next or output connections to the block. 

From some initial experimentation, it doesn't seem like onChange events fire often enough for this to work, maybe I need to look at another way of tackling this?

Mark Friedman

unread,
Feb 7, 2025, 6:06:13 PMFeb 7
to blo...@googlegroups.com
On Fri, Feb 7, 2025 at 2:09 PM Joshua Lowe <joshual...@gmail.com> wrote:
Thanks Mark! This is really interesting and super close to what I was looking at achieving.

I'm using the Zelos renderer, so having a previous, next and output connection on the same block looks a little weird. 

Maybe you could adjust the rendering (via a custom renderer that subclassed the Zelos renderer) to look less weird.  Or see my next comment below.


My idea was to have no connections at all to begin with, so the block is essentially a square, and then, as you drag the block close to a connection, it would dynamically add previous/next or output connections to the block. 

From some initial experimentation, it doesn't seem like onChange events fire often enough for this to work, maybe I need to look at another way of tackling this?

Maybe you could use a custom connection previewer for this.

Good luck and let us (or at least me) know how it goes or if you have any more questions.

-Mark
 

On Friday, February 7, 2025 at 6:05:12 PM UTC mark.f...@gmail.com wrote:
Yes!  I call it a chameleon block and you can see an example of this in my presentation (slide 11) at the 2022 Blockly Summit.  You can find my implementation of it here in my implementation of procedure call blocks for my Scheme Blocks project (which I hope to get back to soon-ish).

-Mark


On Fri, Feb 7, 2025 at 8:21 AM Joshua Lowe <joshual...@gmail.com> wrote:
Hi all,

I'm wondering if it's possible to change a block to an output if it's dragged over a value input, and if it's dragged under a next connection of another block, the block has a previous/next connection instead.

Pointers in the right direction, or knowing if this is simply not possible, would be greatly appreciated!

--
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 visit https://groups.google.com/d/msgid/blockly/2cbbe15c-f2aa-4c6a-bee2-a806f6d9a2f9n%40googlegroups.com.

--
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.
Reply all
Reply to author
Forward
0 new messages