-
Notifications
You must be signed in to change notification settings - Fork 6
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
Keypad work still to do #283
Comments
@amanda-phet do you mind getting a design doc started? |
Also labeling for developer meeting, so we can sort out what needs to be done on NumberKeypad sooner vs later, who is lead developer on the design, who is doing the work, etc. |
11/10/16 design meeting notes: • We need 2 separate keypads: one for numbers, one for entering equations |
We should edit the bullets above to use "expressions", "strings", "text", or something along those lines, rather than "equations" (which implies that there is an equal sign being typed). |
"strings" and "text" is way too general, we're not designing a text editor. How about "mathematical expressions"? |
Revised 11/10/16 design meeting notes: (replaces #283 (comment)) • We need 2 separate keypads: one for numbers, one for entering mathematical expressions |
@pixelzoom and @jonathanolson , @aadish and I (mostly Aadish) have done some work on the Keypad. I think the current form captures most of the architecture that we discussed. I’m mostly out for the next couple of weeks, but since this is going to be needed around the end of January, I thought it would be good for you to take a look and see if you think we’re generally on the right track. There are a number of things that can be improved – for instance, there is a ‘value’ field in |
The bulk of the code can be found in scenery-phet/keypad, and there is demo code in scenery-phet/demo. |
Comments on scenery-phet demo (prior to looking at code):
|
My first pass at the code was a general review, look mainly at conformance to PhET guidelines. Issues:
|
I corrected many of the issues related to code guidelines (check off in the above check list). I also added some On to review of the code architecture... |
First round of architectural review:
The constructor signature of AbstractKey is: function AbstractKey( displayNode, value, identifier ) ... where
The constructor signature is: function BackspaceKey( width, height ) Why can't width and height be provided via options? There are surely reasonable defaults (as there apparently are for other keys). Also wondering... Why does BackspaceKey have these options when Keypad is responsible for button size (via
... and if BackspaceKey is responsible for its dimensions, then why aren't the other subtypes of AbstractKey also responsible for their dimensions? Or the number of cells that they occupy in the grid?
This is apparently done in AbstractKeyAccumulator subtypes via: validateAndProcessInput: function( accumulatedKeys ) I was surprised to see that this function has only one parameter, NOTE: Validation was revised in b8d3bb9, see also #283 (comment).
IntegerAccumulator defines
There's a lot of stuff in IntegerAccumulator that would apply to (for example) DecimalAccumulator. Do you need to factor that out into a more general NumberAccumulator? Highly recommended that you create DecimalAccumulator, and add it to scenery-phet demo. It will illuminate a lot of issues (like this one).
This is another fundamental issue. In the scenery-phet demo, I see: 555 var accumulator = new IntegerAccumulator( { maxLength: 5 } );
568 var keyPad = new Keypad( Keypad.PositiveAndNegativeIntegerLayout, accumulator
576 accumulator.clear();
583 accumulator.setClearOnNextKeyPress( true ); The accumulator should be an internal implementation detail, transparent to the client. Clients shouldn't need to instantiate it, and certainly shouldn't need to explicitly clear it, etc. Keypad (or its subtypes) should provide a complete API. For example... Create NumberKeypad (Keypad subtype), which creates its own NumberAccumulator based on options, and (transparently) provides access to the string and numeric representations of the value. Could also possibly select a default layout based on options. Then scenery-phet demo might look like: var keypad = new NumberKeypad( {
plusMinus: true,
maxDigits: 5
} );
keypad.clear();
keypad.setClearOnNextKeyPress( true );
IntegerAccumulator.updateNumericalValue: 72 return stringRepresentation.length > 0 ? parseInt( stringRepresentation, 10 ) : 0; Absence of a value should most definitely not be mapped to a value of 72 return ( stringRepresentation.length > 0 ) ? parseInt( stringRepresentation, 10 ) : null; |
The current specification of only 2 layouts requires 145 lines! (See Keypad PositiveIntegerLayout and PositiveAndNegativeIntegerLayout.) That specification is verbose, redundant, and makes it very difficult to see the structure of the keypad - especially when keys are specified out of order, as they currently are in both layouts. Suggestions: Then the specification of layouts would look like this: PositiveIntegerLayout: [
[ new DigitKey( 7 ), new DigitKey( 8 ), new DigitKey( 9 ) ],
[ new DigitKey( 4 ), new DigitKey( 5 ), new DigitKey( 6 ) ],
[ new DigitKey( 1 ), new DigitKey( 2 ), new DigitKey( 3 ) ],
[ new DigitKey( 0, { horizontalSpan: 2 } ), new BackspaceKey() ]
],
PositiveAndNegativeIntegerLayout: [
[ new DigitKey( 7 ), new DigitKey( 8 ), new DigitKey( 9 ) ],
[ new DigitKey( 4 ), new DigitKey( 5 ), new DigitKey( 6 ) ],
[ new DigitKey( 1 ), new DigitKey( 2 ), new DigitKey( 3 ) ],
[ new PlusMinusKey(), new DigitKey( 0 ), new BackspaceKey() ]
], This makes it very easy to see the structure of the keypad, and which keys occupy more than 1 grid cell. It also makes it very easy for clients to specify new (custom) layouts. |
In PlusMinusKey: 20 AbstractKey.call( this, '+/-', null, 'PlusMinus' ); ... should be: 20 AbstractKey.call( this, '\u002b/\u2212', null, 'PlusMinus' ); |
From today's dev meeting, I may be able bring this home while working on Projectile Motion for PhET-iO. |
Discussed with @jbphet today, and we checked off the top checkboxes that have been tackled. Game plan for Keypad work this quarter:
Note I gathered this list from looking at https://github.com/issues?q=is%3Aopen+is%3Aissue+user%3Aphetsims+keypad as well as any linked issues around this issue. Anyone feel free to comment on loose ends or other thoughts I may not be thinking about. |
@zepumph is on the case, I'm going to unassign myself for now. |
From #283 (comment):
|
Reopening and turning to an epic |
From a conversation with @kathy-phet this is not a priority for PhET-iO until a client asks for it. Completing keypad work is currently dependent on developer priority. |
The dev team has decided to make this somewhat of a priority, so I've used the "Monday request form" to request that this work be scheduled for an upcoming iteration. I'm going to defer the issue until the work is scheduled. |
@pixelzoom and @amanda-phet have pointed out the need for a general NumberKeypad design meeting. We should look into addressing the following questions as well as fleshing out and prioritizing other anticipated needs
EditableNumberDisplay
#678The text was updated successfully, but these errors were encountered: