Put keyboard text on gui

How can I put a keyboard text on my gui?

On Android and iOS you do gui.show_keyboard() to show the virtual keyboard and gui.hide_keyboard() to hide it. For a complete example of how to deal with text input you could take a look at @sven’s Dirty Larry UI library.

When I use the module Dirty Larry I have this error:

ERROR:SCRIPT: main/lua/dirtylarry.lua:108: No such node: username/bg
stack traceback:
[C]: in function 'get_node’
main/lua/dirtylarry.lua:108: in function 'input’
main/lua/username.gui_script:12: in function <main/lua/username.gui_script:11>

Have you added a node from the input.gui template to your gui scene?

No, I think that I need to use a text node

The template input.gui already include a text node. :slight_smile: dirtylarry functions only works on the prefab gui templates supplied in the library.

but how I need to have it? I need that my gui have for it name input or my gui can have another name

I’m not sure I understand what you mean. If you use the Dirty Larry library you add as many template nodes as you need from the Dirty Larry project, just like Sven showed in his screenshots. You can give them any id you wish.

What do you mean with any id?

Hello Raul,

I believe @britzl is saying that you can assign any name you wish to the node, in the screenshots above would be putting any value in the box “id” (I hope I’m right)

Correct. That was what I meant. But @Raul_Gilabert, I still don’t understand your last question: “but how I need to have it? I need that my gui have for it name input or my gui can have another name”. Could you please explain it more/better?

Yes, I am saying that I don’t understand if my gui node should be called input.gui

If you wish to use the Dirty Larry it is recommended that you use the templates guis provided by the Dirty Larry library. You should not create the individual text nodes yourself. You should right click in the outline of your gui and select Add Template and then select input.gui from Dirty Larry.

I created a recording of me adding and using Dirty Larry in a Defold:

PS You could theoretically create your own input fields and hook them up to Dirty Larry, but in that case you need to replicate the exact same node structure and node ids as in Dirty Larry. I strongly recommend against it.

3 Likes

@britzl And how can I delete text with the Dirty Larry module?

You need to create a key trigger for KEY_BACKSPACE with action “backspace” in your input bindings file.