Closed pixelzoom closed 7 years ago
Btw... I think that this problem is a result of the dubious armForNewEntry
feature in NumberKeypad. The responsibility for clearing the keypad is misplaced - it should be up to the client to clear it explicitly by calling NumberKeypad.clear. And if doing something special with the backspace button is important (which it obviously is in arithmetic and area-builder) then we could add the ability to listen to the backspace button.
I fixed this by moving around where some of the clearing of the user entries occurs. I'd like a little QA time on this to make sure that I caught all cases. The main use case is when the user enters an incorrect value and then, instead of pressing the "Try Again" button, they either start entering a new value or press the backspace key.
Assigning to @phet-steele for testing.
Works just fine 👍
Cleaning up the implementation of the backspace button in NumberKeypad (see https://github.com/phetsims/scenery-phet/issues/280#issuecomment-259477319) causes Arithmetic to behave undesirably. The backspace key should edit the user's previous guess, not clear it.
To demonstrate: • start sim • go to Multiply screen • type '22' on keypad • press 'Check' button • press backspace on keypad • should display '2', but displays ''
The problem is that Arithmetic's state machine is relying on the unnecessary
valueStringProperty.value = ''
that was removed from the backspace button listener in https://github.com/phetsims/scenery-phet/issues/280.To identify the locations in Arithmetic that are causing the problem, I added this to NumberKeypad constructor, immediately after the definition of
valueStringProperty
:Stepping through the demonstration example described above, I identified 2 places where a single press of backspace incorrectly clears the keypad:
(1) WorkspaceNode line 184:
...where
model.retryProblem
is defined in ArithmeticModel, line 156:(2) WorkspaceNode line 146:
Assigned to @jbphet to fix.