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

Broadcast Inputs and Implicit Message Deletion #1302

Merged
merged 5 commits into from
Dec 27, 2017

Conversation

kchadha
Copy link
Contributor

@kchadha kchadha commented Dec 13, 2017

Resolves

Resolves #1268
Resolves #1270
Resolves #1290
Resolves #1304

Proposed Changes

Broadcast blocks (namely broadcast and broadcast and wait) now have pluggable inputs.
New messages can once again be created from the flyout (resolving the issue in #1270).
New messages created from a block in the flyout are created as variables in the flyout's target workspace, thus appearing in all broadcast block dropdown menus.

A message is created when either:

  1. the broadcast block dropdown menu is clicked for the first time OR
  2. any broadcast block with the message selected in its dropdown field is dragged out of the flyout and created on the workspace (this is not new functionality) OR
  3. the message is explicitly created using the New message option in any of the broadcast block dropdowns.

A message is deleted using the implicit deletion behavior from SB2. Most of this functionality is implemented in scratch-vm. A message is deleted (disappears from dropdowns) if all blocks referencing that message are removed from the VM. This deletion behavior updates every time the workspace is updated (e.g. switching sprites or switching between the blocks tab and the costumes/sounds tabs). When the workspace is updated, the broadcast blocks in the flyout update their fields according to SB2 behavior -- the broadcast message that comes first in sorted order will appear selected in the field of each of the broadcast blocks in the flyout. The sorting behavior is the same as that used to sort the options in the dropdown menu (alphanumeric sorting by message name).

The assertion that shadows cannot have variables is no longer true, so the assertion statement has been removed.

Diversions from SB2

SB2 projects that have empty string message names will be converted to a fresh name message#.
In SB2, plugging in an input, e.g. ((1) + (1)), into a broadcast [foo] or broadcast [foo] and wait block, and then taking that input back out will result in removing the old message name foo and replacing it with the empty string. In the proposed changes, foo will remain in the message dropdowns, as well as in the shadow behind the plugged in input.

The reason for these divergences are to avoid the potential for buggy behavior when introducing this round-about way of creating empty string message names when they are otherwise disallowed from explicit creation.

If we decide that we would like to maintain this SB2 behavior, that change can be made.

Reason for Changes

To maintain compatibility with Scratch 2.0 which allows blocks to be plugged into the broadcast block inputs, and has the implicit deletion behavior.

Test Coverage

Existing tests pass.

Additional Notes

This PR depends on corresponding PRs in scratch-vm and scratch-gui:
LLK/scratch-gui#1033
LLK/scratch-vm#860

These three PRs can be tested together here.

@rachel-fenichel
Copy link
Collaborator

No variables in shadows: read this thread.

@kchadha
Copy link
Contributor Author

kchadha commented Dec 14, 2017

@rachel-fenichel, thanks for the pointer to the thread. That makes a lot of sense. I guess this should also factor into the discussion for #1290. If we explicitly disallow deletion/renaming for broadcast messages (not saying this is what will necessarily happen), would this then be a non-issue? e.g. Is deletion/renaming the only consideration we should make when deciding to have a field_variable in a shadow?

@rachel-fenichel
Copy link
Collaborator

I think deletion/renaming is the only concern, but it includes implicit deletion/renaming.

Variable fields may now be better at creating variables at the right time, so maybe it's okay. I would experiment with some of the workflows from that thread to see if anything ends up feeling too weird.

@kchadha
Copy link
Contributor Author

kchadha commented Dec 15, 2017

Right now I have no deletion of broadcast messages implemented at all (explicit or implicit), so testing that out will probably have to wait until we make a decision about what deletion behavior should be.

@kchadha kchadha force-pushed the broadcast-input-fields branch from f9458a6 to ef3acb8 Compare December 18, 2017 15:37
@kchadha kchadha changed the base branch from broadcast-messages to develop December 18, 2017 16:50
@kchadha kchadha changed the base branch from develop to broadcast-messages December 18, 2017 16:51
@kchadha
Copy link
Contributor Author

kchadha commented Dec 18, 2017

@paulkaplan Does it make sense to change this and corresponding PR's mentioned above to be against develop instead of these new separate branches ('broadcast-messages' branch)?

My original intuition for the separate branches was so that they would be a staging area for all of the new broadcast block changes (including merging in Rachel's changes from upstream blockly). I think this might not make sense anymore, since merging in Rachel's work will be a pretty substantial change/refactor anyways, and it's not planned for our current milestone.

@thisandagain thisandagain added this to the December milestone Dec 20, 2017
@kchadha kchadha force-pushed the broadcast-input-fields branch from ea81b30 to 43b3e60 Compare December 22, 2017 00:10
…ble shadows. Flyout stuff needs to be fixed.
) and ensuring that the message1 shows in the dropdown by defualt. 'message1' gets created as a variable on the flyout's target workspace upon dropdownCreate.
…ow follow scratch 2 behavior of displaying the message that comes first in sorted order (same sort as dropdown)
@kchadha kchadha changed the title Broadcast input fields Broadcast Inputs and Implicit Message Deletion Dec 22, 2017
@kchadha kchadha changed the base branch from broadcast-messages to develop December 22, 2017 14:57
@kchadha kchadha force-pushed the broadcast-input-fields branch from 43b3e60 to 8447633 Compare December 22, 2017 15:20
var broadcastMsgType = Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE;
var broadcastVars = this.sourceBlock_.workspace.getVariablesOfType(broadcastMsgType);
if (this.variableType == broadcastMsgType && broadcastVars.length != 0) {
broadcastVars.sort(Blockly.VariableModel.compareByName);

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Contributor

@paulkaplan paulkaplan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@paulkaplan paulkaplan merged commit 673d50e into scratchfoundation:develop Dec 27, 2017
@rachel-fenichel
Copy link
Collaborator

Did you check for problems related to variables in shadows?

@kchadha
Copy link
Contributor Author

kchadha commented Jan 8, 2018

@rachel-fenichel I believe we don't have any issues with variables in shadows right now. Variables in shadows aren't implicitly deleted unless all blocks (including obscured shadows) with a particular variable are deleted.

This is not the same behavior as in scratch 2 where a block covering a shadow deletes the underlying variable in the shadow field.

We decided to avoid this in Scratch 3 (unless an issue with it comes up) because in Scratch 2, this is how the empty string names are created, and we wanted to avoid those in Scratch 3, if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants