I am really excited to use the string variables that have been recently added to Figma. I want to implement a string variable and to delete the last character of the string every time the delete key is pressed.
I’m not finding much documentation on the string variables yet, but I know that it’s new. Has anyone figured out how to delete the last character of a string variable in a prototype?
You can’t remove characters from strings afaik, so you’ll have to fake it. You could make each letter its own layer, and toggle it’s visibility based on a number variable that decreases on every key press.
I had a similar situation and had an idea on how to handle it: You can store the result from the previous iteration in a separate variable before adding characters each time with set variable. For example, before doing set variable: [name] = [name] + “a”, you could do set variable: [name - previous input] = [name] to save the value beforehand. That way, when you need to remove something, you can execute: set variable: [name] = [name - previous input] to revert it back to the previous value.
create a temporary variable to hold the previous string before the character insertion. It will work only for 1 character though