phetsims / unit-rates

"Unit Rates" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 2 forks source link

Pressing two or more edit buttons at once creates multiple keypads #181

Closed phet-steele closed 7 years ago

phet-steele commented 7 years ago

Pressing multiple edit buttons at once, with multiple fingers, "creates" multiple keypads. This can be any combination of edit buttons, whether they are for a marker or in the question panel. This is only doable with a touchscreen and multitouch (so far only on iOS, haven't been successful on Win 10 Chrome).

To demonstrate:

  1. It's easiest to "prime" your fingers by pressing and holding on two different edit buttons. I'd recommend for your first try to choose one edit button for a marker and one for a question.
  2. Lift both fingers off the screen simultaneously.
  3. If you've done this right, both text areas you are trying to edit will be highlighted yellow.
  4. Dismissing a keypad, whether you enter and submit an answer or simply press the barrier rectangle, you'll notice that one of the text areas remain highlighted.
  5. The keypad associated with the still highlighted text area in step 4 will now always appear when pressing any other edit button. Trying to submit a value with this problematic keypad does nothing.

Running this procedure multiple times with both marker edit buttons (in a new position each time so the keypads don't overlap) can produce a very cluttered screen: img_0072

@pixelzoom let me know if you want a video, I don't want to make it if no one needs it.

Seen on iPad Air 2 iOS 10.2. For phetsims/tasks#797. URL: http://www.colorado.edu/physics/phet/dev/html/unit-rates/1.0.0-dev.68/unit-rates_en.html Version: 1.0.0-dev.68 2017-03-07 05:58:25 UTC Features missing: touch Flags: pixelRatioScaling User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Language: en-US Window: 1920x1001 Pixel Ratio: 2/1 WebGL: WebGL 1.0 (OpenGL ES 2.0 Chromium) GLSL: WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium) Vendor: WebKit (WebKit WebGL) Vertex: attribs: 16 varying: 32 uniform: 1024 Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 80) Max viewport: 16384x16384 OES_texture_float: true Dependencies JSON: {"assert":{"sha":"a707328c","branch":"master"},"axon":{"sha":"e0b1c391","branch":"master"},"babel":{"sha":"88805de4","branch":"master"},"brand":{"sha":"0be722ee","branch":"master"},"chipper":{"sha":"43ca9ac4","branch":"master"},"dot":{"sha":"16c2f26b","branch":"master"},"joist":{"sha":"695d3638","branch":"master"},"kite":{"sha":"f4c67cff","branch":"master"},"phet-core":{"sha":"c5c6c2a8","branch":"master"},"phetcommon":{"sha":"49b5cb0d","branch":"master"},"query-string-machine":{"sha":"d8a4ff18","branch":"master"},"scenery":{"sha":"04879a99","branch":"master"},"scenery-phet":{"sha":"0bb107fe","branch":"master"},"sherpa":{"sha":"98566566","branch":"master"},"sun":{"sha":"dc8dcfbf","branch":"master"},"tandem":{"sha":"45e9ee17","branch":"master"},"twixt":{"sha":"2ffed75c","branch":"master"},"unit-rates":{"sha":"4712352f","branch":"master"}}

pixelzoom commented 7 years ago

The problem here is that buttons fire when they are released ("pointer up"). The easy resolution is to change the edit buttons to fire on press ("pointer down"), but that will mean that they are slightly non-standard. Let me mull this over to see if I can come up with a better solution.

phet-steele commented 7 years ago

The easy resolution is to change the edit buttons to fire on press ("pointer down")

@pixelzoom wouldn't that just mean I could change step 1 in the procedure to not begin with pressing and holding two buttons? I would instead just press the screen at the same time with two fingers.

pixelzoom commented 7 years ago

@phet-steele said:

I would instead just press the screen at the same time with two fingers.

It's impossible to generate 2 scenery input events at exactly the same time. Even if you actually managed to press the screen with multiple fingers at exactly the same time, scenery input events are ordered, and 1 of the 2 events will be delivered before the other. And the first event will open the keypad, which blocks any subsequent events from being delivered to anything but the keypad.

pixelzoom commented 7 years ago

@phet-steele I pushed a fix to master. Attempts to open a second keypad are now simply ignored. I don't have an iPad handy, so would appreciate it if you could verify. (Make sure that the value boxes don't change color.) Thanks.

phet-steele commented 7 years ago

Cannot yet verify, error on attempt to cause the issue. However, looks promising.

TypeError: unitRates.log is not a function. (In 'unitRates.log( 'ignoring attempt to open another keypad' )', 'unitRates.log' is undefined)
beginEdit — KeypadLayer.js:74
editNumerator — MarkerEditorNode.js:174
(anonymous function) — PushButtonModel.js:142
forEach
fire — PushButtonModel.js:141
(anonymous function) — PushButtonModel.js:84
emit2 — Emitter.js:147
_notifyObservers — Property.js:210
_setAndNotifyObservers — Property.js:199
set — Property.js:143
up — ButtonListener.js:49
buttonUp — DownUpListener.js:123
up — DownUpListener.js:56
dispatchToPointer — Input.js:773
dispatchEvent — Input.js:746
upEvent — Input.js:623
touchEnd — Input.js:403
run — BatchedDOMEvent.js:67
fireBatchedEvents — Input.js:203
batchEvent — Input.js:179
batchWindowEvent — BrowserEvents.js:279
ontouchend — BrowserEvents.js:434
pixelzoom commented 7 years ago

Ah, sorry @phet-steele, I forgot to check whether logging was enabled. Fix pushed to master, please try again.

pixelzoom commented 7 years ago

If you add ?log query parameter, you should see a log message (in the console) like this for each attempt to open a duplicate keypad:

ignoring attempt to open another keypad

phet-steele commented 7 years ago

Looks good.