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

Instrument Keypad.js for PhET-iO #540

Open
Tracked by #283
zepumph opened this issue Oct 11, 2019 · 20 comments
Open
Tracked by #283

Instrument Keypad.js for PhET-iO #540

zepumph opened this issue Oct 11, 2019 · 20 comments

Comments

@zepumph
Copy link
Member

zepumph commented Oct 11, 2019

This is needed for phetsims/projectile-motion#177. I'll take a first pass at this, but I think it will want some PhET-iO design time too.

Design Questions:

  • Does AbstractKeyAccumulator.accumulatedKeysProperty need to be instrumented?
@zepumph
Copy link
Member Author

zepumph commented Oct 25, 2019

From first design meeting, the notes were to have the most minimal instrumentation to support record/payback and data stream from user inputs. It also seemed valuable to be able to get the value out of the keypad. @samreid will you please review the current instrumentation. A great way to do that is in Projectile Motion studio. The lab screen -> custom options in the combobox -> press a yellow "edit" button to pop up the keybad.

@samreid
Copy link
Member

samreid commented Oct 25, 2019

the notes were to have the most minimal instrumentation to support record/payback

Scenery input event recording does not require UI components to be instrumented, right?

@zepumph
Copy link
Member Author

zepumph commented Oct 25, 2019

Sorry, I edited that above.

@samreid
Copy link
Member

samreid commented Oct 25, 2019

Thanks! What's the timeline for this sim? Should this review be bundled with other review?

@zepumph
Copy link
Member Author

zepumph commented Oct 25, 2019

Same timeline for Gravity and Orbits I believe, asap for the phet-io developer as it can be balanced with dynamic state.

@samreid
Copy link
Member

samreid commented Nov 6, 2019

Things look pretty good. A few questions. I was surprised to see the "enterButton" was a sibling of the "keypad"--should they be more closely related, sharing a nearer parent or something? Also, do you like dynamically creating the tandem names like keyPadTandem.createTandem( `${_.camelCase( keyObject.identifier )}Button` )? I have experimented with creating "whole" tandem names earlier, such as keyPadTandem.createTandem( keyObject.buttonTandemName ). Also, (could be a separate issue) are you surprised that Key is all based on strings and not numbers?

@samreid samreid assigned zepumph and unassigned samreid Nov 6, 2019
@zepumph
Copy link
Member Author

zepumph commented Nov 6, 2019

I was surprised to see the "enterButton" was a sibling of the "keypad"--should they be more closely related, sharing a nearer parent or something?

I think this is fine to me, as enter is part of the current keypad implementation. I can only assume that there was a reason that that was not implemented as part of the keypad (likely for flexibility if you don't want to have a submit style entry?). Perhaps someone like @jbphet would know why the enter button didn't make it into Keypad.js as I think he worked on it with @aadish a while back.

Also, do you like dynamically creating the tandem names like keyPadTandem.createTandem( ${_.camelCase( keyObject.identifier )}Button )? I have experimented with creating "whole" tandem names earlier, such as keyPadTandem.createTandem( keyObject.buttonTandemName ).

So would you rather have a field in Key.js that looks like this?

    this.buttonTandemName = _.camelCase( keyObject.identifier )}Button

That feels like an improvement to me. I'll implement.

Also, (could be a separate issue) are you surprised that Key is all based on strings and not numbers?

Strings feels right to me here. It makes it more general for things like the backspace or . button. Does that seem reasonable to you? If not please make an issue with your thoughts.

zepumph added a commit that referenced this issue Nov 6, 2019
@zepumph zepumph assigned samreid and jbphet and unassigned zepumph Nov 6, 2019
@samreid
Copy link
Member

samreid commented Nov 7, 2019

Not feeling 100% great about any of the proposals (including the one below), but the one I had in mind was new Key( '7', KeyID.SEVEN, '7Button' ). The philosophy is to make all tandems 100% searchable, and not using string concatenation for any tandem term construction.

@samreid samreid assigned zepumph and unassigned samreid Nov 7, 2019
@zepumph
Copy link
Member Author

zepumph commented Nov 9, 2019

From phetsims/projectile-motion#177 design meeting, here are two more items:

  • instrument the KeypadLayer
  • knowing when the keypad is shown.

@samreid's item:

zepumph added a commit to phetsims/projectile-motion that referenced this issue Nov 13, 2019
@zepumph
Copy link
Member Author

zepumph commented Nov 13, 2019

@samreid, I understand your concern, and know that up until this point, we have refactored to make this pattern consistent. I think the main reason I am uninterested in it here is for two reasons.

  • The word "Button" doesn't feel like it belongs as a definitive param to Key. In my commit, note that I called it the "buttonTandemName".
  • (subjective) It doesn't seem more valuable to have it that way, just more busy work. If in the future we instrumented Key.js, then needing to pass a tandem to all Key instances may be required. But why do that before it is necessary?

@arouinfar
Copy link

@kathy-phet and I reviewed this as a part of phetsims/projectile-motion#244.

We don't think clients need to customize the keypad, and things could get pretty weird if they start removing individual buttons or messing with enabledProperties. The model should be the only thing controlling whether or not the keypad is visible/enabled, so everything should be read only. Similarly, nothing needs to be phetioFeatured. There are lots of buttons which by default have their enabledProperty and visibleProperty featured, but ideally these would be unfeatured within keypad (rather than doing it in the overrides for every sim).

State is not currently being saved correctly. In Projectile Motion > Lab Screen > Custom, open a keypad and type in a value. Launch the sim, and the range string (e.g. 1 - 5000 kg) and the value in the numberAccumulator will be cleared.

@arouinfar arouinfar removed their assignment Feb 23, 2021
@zepumph zepumph changed the title Instrument Keypad for PhET-iO Instrument Keypad.js for PhET-iO May 13, 2021
@zepumph
Copy link
Member Author

zepumph commented Jul 14, 2022

This will most likely block Projectile Motion publication, which we may get to in a couple of months.

@marlitas
Copy link
Contributor

marlitas commented Apr 6, 2023

This seems like a good contender for @matthew-blackman and I this iteration since it relates to Projectile Motion. Tagging it as such.

@zepumph
Copy link
Member Author

zepumph commented Nov 8, 2023

104bad5 broke collision-lab by call createTandem on undefined. Fixed above.

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

No branches or pull requests

8 participants