NetsBlox / Snap--Build-Your-Own-Blocks

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
3 stars 6 forks source link

Get focus on load? #1513

Closed gsteinLTU closed 6 months ago

gsteinLTU commented 7 months ago

Related to #1511

Key shortcuts currently do not work until the user has clicked on the canvas. I think it makes sense for a user to immediately want to press ctrl/command+O to open a project. Snap! seems to focus itself automatically (I think it's https://github.com/jmoenig/Snap/blob/5937085ed8c0837f82d7372d1eb938ae7fc07362/src/gui.js#L434 , but we have similar ), we should do the same (when not running in an iframe?).

brollb commented 7 months ago

Hmm... This needs further exploration as we have the same logic (line 155 of gui-ext.js)

gsteinLTU commented 7 months ago

It looks like it's not the world canvas that needs focus, it's the morphic_keyboard. On Snap, document.activeElement is set to it on load, while NetsBlox does have the canvas focused.