tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
185 stars 42 forks source link

Autofocus not working on first passage #226

Closed manonamora closed 4 months ago

manonamora commented 1 year ago

Describe the bug. The autofocus option from textboxes does work on the first loaded or playable passage. It works as intended if the textbox with autofocus is coded on any other passage (as long as it's not the first)

To Reproduce: Steps to reproduce the behavior:

  1. <<textbox "$pie" "Blueberry" autofocus>> on the first playable passage/
  2. Open the passage in browser.

Expected behavior. The autofocus should be working even if it is the first loaded passage.

Project details.

Desktop details.

manonamora commented 1 year ago

I was working on something else, and found that the autofocus on the textbox also doesn't work when it is inside a <<timed>> macro. (sorry for adding on the bug fix...)

tmedwards commented 1 year ago

It's related, so you get a pass. 😄

tmedwards commented 1 year ago

And that should fix every delayed insert issue—e.g., <<replace>>, <<type>>, custom user code, etc.

manonamora commented 1 year ago

Hopefully last comment on this (sorry!) the autofocus doesn't work if the <<textbox>> is inside a dialog popup either 😬 (or anywhere that is not in #passages) (If this is normal behaviour, maybe to leave a note on the documentation?)

tmedwards commented 1 year ago

I'll test it to make sure, but it's probably already been fixed.

Also, a thought. Are you sure you should be autofocus'ing this much? Stealing focus from the player is something that should normally be done sparingly, especially if done after passage load—e.g., via <<replace>>, <<type>>, <<timed>>, etc. It can be pretty jarring for impaired players that keyboard, rather than mouse. Just something to consider.

manonamora commented 1 year ago

Oh, each report were stuff I noticed on different projects where it's used once or twice :)

tmedwards commented 1 year ago

Tested and confirmed fixed inside dialogs as well.