Blocks and Hats

662 views
Skip to first unread message

Jorge Bonafé

unread,
Aug 21, 2017, 10:10:15 AM8/21/17
to Blockly
My application has a "Main" type block and several "Event" type blocks. I understand how to add hats to all blocks, but I can't figure out how to add hats only to the event blocks, and not the Main block. Is that possible? I'm trying to do that on all versions of blockly, web, ios and android.

Thanks in advance

Neil Fraser

unread,
Aug 21, 2017, 10:37:32 AM8/21/17
to blo...@googlegroups.com
Currently it is an all-or-nothing option for blocks that have no previous connections or output connections.  However, you are definitely not the first person to request selective hat availability.

On 21 August 2017 at 15:10, Jorge Bonafé <jorge...@gmail.com> wrote:
My application has a "Main" type block and several "Event" type blocks. I understand how to add hats to all blocks, but I can't figure out how to add hats only to the event blocks, and not the Main block. Is that possible? I'm trying to do that on all versions of blockly, web, ios and android.

Thanks in advance

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Jorge Bonafé

unread,
Aug 21, 2017, 4:56:07 PM8/21/17
to Blockly
Allright, in the meantime I forked it and made the changes on IOS myself. I'll do something on the other versions later.

I added a json boolean property "startHat: true" that sets it to show the hat on the desired block.
If anyone is interested, the code is here:

Jorge Bonafé

unread,
Aug 22, 2017, 2:24:46 PM8/22/17
to Blockly

Victor Ng

unread,
Sep 20, 2017, 4:36:51 PM9/20/17
to Blockly
Thanks for pointing this out Jorge. We had a team discussion and we agreed that this is useful!

As of PR #449 on iOS, it now accepts individual hats per block. You can specify it on the block JSON definition as follows:

eg.
{
  "name": "some_block",
  "style": {
    "hat": "cap"
  }
}

Possible values for "hat" are:
"cap"
"none"

We're working to get it implemented on the other platforms as well. Here are the open issues for those:

Jorge Bonafé

unread,
Sep 20, 2017, 4:51:41 PM9/20/17
to Blockly
Allright, I'll update my code. Thank you.

Andrew n marshall

unread,
Sep 20, 2017, 4:53:16 PM9/20/17
to blo...@googlegroups.com
Jorge,

When you do, would you mind making pull request, based on the develop branch?  It would be much appreciated.
On Wed, Sep 20, 2017 at 1:51 PM, Jorge Bonafé <jorge...@gmail.com> wrote:
Allright, I'll update my code. Thank you.

--

Jorge Bonafé

unread,
Sep 20, 2017, 4:57:38 PM9/20/17
to Blockly
Forgive my lack of understanding of git, can you clarify what that means?

Andrew n marshall

unread,
Sep 20, 2017, 5:36:32 PM9/20/17
to blo...@googlegroups.com
A pull request is a GitHub process for developers to contribute code to a repository they do not own, complete with a code review pass.

Basically, after checking out a copy of Google's develop branch, make the changes there upload it back to github under a new branch name. Then, when you go to the GitHub page for your fork or our original, you'll see a button to make a pull request based on your new branch.

These two pages seem to have more details:


If this seems complicated, your code looks small enough I can copy the work manually, if need be.

Thanks.


On Wed, Sep 20, 2017 at 1:57 PM, Jorge Bonafé <jorge...@gmail.com> wrote:
Forgive my lack of understanding of git, can you clarify what that means?

--

Jorge Bonafé

unread,
Sep 20, 2017, 6:15:31 PM9/20/17
to Blockly
I see. But I was under the impression the changes were already made on the official code. Or do you mean you'd like me change my Android fork to reflect the changes on the IOS version?

If that's the case, the thing is, I changed a bunch of other unrelated stuff on my Android fork. Wouldn't that be a problem?

Andrew n marshall

unread,
Sep 20, 2017, 7:00:18 PM9/20/17
to blo...@googlegroups.com
You've made changes on your fork. Note the jorgebonafe in the following URL:

On Wed, Sep 20, 2017 at 3:15 PM, Jorge Bonafé <jorge...@gmail.com> wrote:
I see. But I was under the impression the changes were already made on the official code. Or do you mean you'd like me change my Android fork to reflect the changes on the IOS version?

If that's the case, the thing is, I changed a bunch of other unrelated stuff on my Android fork. Wouldn't that be a problem?

--

Jorge Bonafé

unread,
Sep 20, 2017, 7:34:05 PM9/20/17
to Blockly
What I mean is, I also made changes that have nothing to do with the hat code, so I'm wondering if that's not a problem when I do the pull request with all those other unrelated changes.

In any case, I did the pull request. Let me know if I did that correctly.

Andrew n marshall

unread,
Sep 21, 2017, 11:19:21 AM9/21/17
to blo...@googlegroups.com
Because it has so many other changes, I'm going to decline this PR. This is why PRs should generally start with a clean copy of the develop branch.

But this is not a big problem. I'm happy to make the PR myself. It will just take more time to get it in. It may cause minor conflicts if you pull from our repo in the future, but they should be trivial to resolve.
On Wed, Sep 20, 2017 at 4:34 PM, Jorge Bonafé <jorge...@gmail.com> wrote:
What I mean is, I also made changes that have nothing to do with the hat code, so I'm wondering if that's not a problem when I do the pull request with all those other unrelated changes.

In any case, I did the pull request. Let me know if I did that correctly.

--
Reply all
Reply to author
Forward
0 new messages