[SugarCube] Typing sim custom macro; displaying keyboard on mobile devices?

Excalibur (Twine 2, SugarCube 2.x) features a few instances of Chapel’s typing sim macro, but clicking into typing sim textareas doesn’t bring up the keyboard on mobile devices, meaning that the game can currently only be played on laptops and desktop computers. We’d love to resolve that for better compatibility with other devices.

Is there a way to force the keyboard to display on a phone or tablet when a textarea element is in focus?

1 Like

I’ve been meaning to do something about this but I haven’t had time. I plan to probably make it so you tap the text area to fill in the message, either one letter at a time or all at once. Bringing up the software keyboard, afaik, isn’t really a viable solution.

Edit: Actually I think there is a way to do this. I’ll report back soon.

2 Likes

https://twinelab.net/custom-macros-for-sugarcube-2/#/type-sim

I’ve updated the <<typesim>> macro and it should now be mobile friendly. The new version should be compatible with the old version in terms of code, so you can just replace it in the JavaScript to update.

2 Likes

That’s brilliant news, Chapel! Thanks very much for your work on this.

2 Likes

Thank you so much, this is exciting!

I’m running into one issue. I replaced the old JS with the new, but when I test, the error “[tw-user-script-0]: Macro.add(…) is not a function” comes up. Textareas are now replaced with “Error: macro <> does not exist,” but anything between the macro tags is still displayed.

1 Like

That’s really weird and doesn’t make a whole lot of sense. Not sure if I can fix that. I can double check to make sure the script works again later. You aren’t using some horribly outdated version of SugarCube, right?

I’ll let you know what happens when I check the script, but I did test it. In fact, I uploaded the test file to check mobiles, and its still there and working: typesim

1 Like

We’re using 2.34.1, but we also have a small amount of other JavaScript set up. I tried rearranging the JS so that the typesim script is at the top and everything else below it, and everything’s working exactly as it should now.

So sorry for the inconvenience; I should have thought of that sooner. I’m certain you tested everything thoroughly by the time you first updated; I just managed to organize our JS weirdly.

Thanks so much for taking the time to look at this and even modify the macro. Your work is fantastic and much-appreciated!

1 Like

It should work anywhere. That it doesn’t suggests to me that there could be an error somewhere in your JS code, so that may be something worth looking into.

1 Like

That makes sense. I’ll definitely look into that and figure out what’s up. Thanks again for your help!

1 Like

Thanks to you both for getting this working! :grinning:

2 Likes