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

add 'field helper' concept to connections #62

Merged
merged 1 commit into from
Aug 29, 2017

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Aug 24, 2017

The concept here is that we want to be able to add the ability for certain inputs/connections to augment the fields being attached to them with certain helpers. Specifically, we want for Artist blocks with value inputs like this one

image

To still be able to show the Angle Helper:

image

This PR proposes a generic system to do that. When we define the inputs for the block, in addition to validation checks we can add a Field Helper like so:

  blockly.Blocks.draw_turn = {
    // Block for turning left or right.
    helpUrl: '',
    init: function () {
      this.setHSV(184, 1.00, 0.74);
      this.appendValueInput('VALUE')
        .setCheck(blockly.BlockValueType.NUMBER)
        .addFieldHelper(blockly.BlockFieldHelper.ANGLE_HELPER, {
          block: this,
          directionTitle: 'DIR',
        })
  ...

And then Fields can consult getFieldHelperOptions_ from within showEditor_ to see if they are (at the time of editing) in a connection hierarchy that wants them to show a helper, meaning we can dynamically display the angle helper based not on the field itself, but based on the input it's connected to!

ah

I'd love to get y'all's general thoughts on this approach.

Copy link
Contributor

@balderdash balderdash left a comment

Choose a reason for hiding this comment

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

This looks great!

Copy link

@ryansloan ryansloan left a comment

Choose a reason for hiding this comment

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

🎉

@Hamms Hamms merged commit 69ae094 into staging Aug 29, 2017
Hamms added a commit to code-dot-org/code-dot-org that referenced this pull request Sep 11, 2017
@balderdash balderdash deleted the add-connection-field-helpers branch March 15, 2018 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants