Clear text of textbox after a click

Hello. I’m new to Twine.
In the textbox, I ask the player to enter a name.

<<textbox "$name" "Enter a name">>

When the player clicks in the textbox, the inscription “enter a name” does not disappear. The player has to delete the inscription. How do I make the textbox clear by mouse click? Please, help.

Twine Version: 2.3.15
Story Format: SugarCube 2.34.1

The easiest thing to do would be to not use the default text argument as placeholder text. Just add a separate label. E.g.,

Enter a name:
<<textbox "$name" "">>

Or, including a <label> wrapper for accessibility:

<label>Enter a name:
<<textbox "$name" "">></label>

If you’d like a textbox where you can have some text that shows inside of the textbox until you start typing in there, then you might want to take a look at the “<<textboxPlus>> Widget” section of my Twine/SugarCube sample code collection.

With that widget added to your game, you can then use the “placeholder” text in a <<textboxPlus>> widget to do what you want, something like this:

<<textboxPlus "Name:" "$name" `{ placeholder: "Enter a name here" }`>>

The widget allows you a lot of other options as well which the default <<textbox>> macro does not support. See the documentation at the above link for details.

Enjoy! :slight_smile:

1 Like

Thank you, kind man!

Thanks, I’ll try!