phetsims / quadrilateral

"Quadrilateral" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 3 forks source link

Shift + mouse don't always work in iframes #447

Closed Nancy-Salpepi closed 1 year ago

Nancy-Salpepi commented 1 year ago

Test device MacBook Air M1 chip

Operating System 13.4

Browser Safari 16.5

Problem description For https://github.com/phetsims/qa/issues/961, during the iframe test, the shift + mouse shortcut only works after tabbing into the sim.

Steps to reproduce

  1. Open https://phet-dev.colorado.edu/html/quadrilateral/1.1.0-rc.1/phet/quadrilateral_all_iframe_phet.html
  2. Hold down shift and use the mouse to try and move a side or corner--It doesn't move in small steps
  3. Tab into the iframe
  4. Hold down shift and use the mouse to try and move a side or corner--It moves in small steps
Troubleshooting information: !!!!! DO NOT EDIT !!!!! Name: ‪Quadrilateral‬ URL: https://phet-dev.colorado.edu/html/quadrilateral/1.1.0-rc.1/phet/quadrilateral_all_phet.html Version: 1.1.0-rc.1 2023-06-28 19:27:03 UTC Features missing: applicationcache, applicationcache, touch Flags: pixelRatioScaling User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.5 Safari/605.1.15 Language: en-US Window: 1388x706 Pixel Ratio: 2/1 WebGL: WebGL 1.0 GLSL: WebGL GLSL ES 1.0 (1.0) Vendor: WebKit (WebKit WebGL) Vertex: attribs: 16 varying: 30 uniform: 1024 Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32) Max viewport: 16384x16384 OES_texture_float: true Dependencies JSON: {}
Nancy-Salpepi commented 1 year ago

The same goes for option + shift + r option + r option + c

jessegreenberg commented 1 year ago

Alright, I looked into this. For security reasons, there is no way for the child iframe to receive keyboard events unless it has focus. A simple workaround is described here https://stackoverflow.com/questions/10942523/catch-all-keyup-keydown-events-in-iframe but it is not general and only works if parent and child iframes share the same domain.

So unfortunately we can't do anything about this @Nancy-Salpepi, but thanks for noticing. Also, @brettfiedler @terracoda FYI that this limitation exists for alternative input. Closing.