Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block has default input blocks ? #23

Open
vml933 opened this issue Jun 30, 2021 · 2 comments
Open

Block has default input blocks ? #23

vml933 opened this issue Jun 30, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@vml933
Copy link

vml933 commented Jun 30, 2021

Hello,
I want to do : when user drag block(math_arithmetic) on canvas, it default has to 2 block(math_number) in the block(math_arithmetic) slots, not 2 empty slot.

Is it possible to do that ? can you give me some tip?
Thanks.

@imagicbell
Copy link
Owner

This is a very good suggestion.
Google Blockly has this feature. I didn't move this to ublockly. But it can be done. I've checked the google's code. They append the default input into the block in the initialization phase. That is to build a block, we not only create the original block object, but also connect the default input block.
But in ublockly, we might have a simpler implementation. My thought is:


When we drag the block from the tool box into workspace, in addition to clone the original block object, we also check the input, create the input block and connect it to the parent block.


I will add this feature in the future. However, if you would like to have a try, PR is welcome:smile:

@vml933
Copy link
Author

vml933 commented Jul 2, 2021

Hello:
I have some progress, similar your thought: drag the block to workspace, then check the input and create block and append,
but my codes is dirty for now ,I try to solve it.

Thanks your help.

@imagicbell imagicbell added the enhancement New feature or request label Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants