Move block manually

157 views
Skip to first unread message

yixin

unread,
Apr 20, 2021, 9:40:55 PM4/20/21
to Blockly
Hello, i want to know is there any way to move block, i no find this kind of api, maybe i miss? and is `Blockly.Events.BLOCK_DRAG` only triggered when drag start and drag end?

Beka Westberg

unread,
Apr 21, 2021, 9:11:11 PM4/21/21
to blo...@googlegroups.com
Hello,

I think you'll want to look at the moveBy function. Note that this is in *workspace units* not pixels, so you may have to do some conversions depending on what you're trying to do =)

I believe BLOCK_MOVE is only triggered at the start and end yes, but I'm not sure :/

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

On Tue, Apr 20, 2021 at 6:40 PM yixin <quc...@qq.com> wrote:
Hello, i want to know is there any way to move block, i no find this kind of api, maybe i miss? and is `Blockly.Events.BLOCK_DRAG` only triggered when drag start and drag end?

--
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/7e35d5a7-51bc-421d-818d-0eb3a63cfd5bn%40googlegroups.com.

yixin

unread,
Apr 22, 2021, 11:25:36 PM4/22/21
to Blockly
Hi Beka,
thank you for your reply.

Is there any event that trigger when block move like `onmousemove` html event, i would like to record and show the position every the block move

Thanks!

Beka Westberg

unread,
Apr 23, 2021, 4:38:31 PM4/23/21
to blo...@googlegroups.com
Sadly, not that I'm aware of :/ I think that Blockly tries to limit the number events it's firing, because of the way the custom event system works. If too many events are being fired, it can make the whole workspace laggy.

I think in the next release of Blockly you might be able to create a custom block dragger to serve this purpose? But the core team doesn't provide information until the release actually goes out, so I'm not sure. Abby may have more information about it =)

Sorry I can't be more help :/
--Beka

Abby Schmiedt

unread,
Apr 23, 2021, 7:57:10 PM4/23/21
to Blockly
Hello!

Yes, after the June 2021 release of Blockly you will be able to create a custom block dragger. This means that you would be able to override the dragBlock method and emit your own event.

Cheers,
Abby

yixin

unread,
Apr 24, 2021, 10:37:42 PM4/24/21
to Blockly
Hello !

I look forward to the release !

Thank you both Beka and Abby.

Cheers,
Yixin
Reply all
Reply to author
Forward
0 new messages