Page 1 of 1

GuiElement Textfield localised .text

Posted: Thu Sep 15, 2016 2:19 pm
by matjojo
I need to put a placeholder in a textbox,

To do that I tried this:

Code: Select all

gui.center.add{type = "textfield", name = "texboxname", text = {"gui.placeholder-text"}}
But when doing this no text appears, which is weird, because when doing this:

Code: Select all

gui.center.add{type = "textfield", name = "texboxname", text = "placeholder"}

it does add the string "placeholder" in the textbox.

I also tried this:

Code: Select all

d.gui.center.add{type = "textfield", name = "textboxname"}
placeholder = {"gui.placeholder-text"}
d.gui.center.textboxname.text = placeholder	
but this gives an error telling me I need a string and not a table.


any ideas?

Re: GuiElement Textfield localised .text

Posted: Thu Sep 15, 2016 3:02 pm
by aubergine18
Captions are localisable.... But textfield doesn't have a .caption.

It only has a .text property, which is the text that appears in text box.

And from what I can remember, it's not localisable (as the assumption is that the player will type stuff in there)

If you want some descriptive text, you'll need to add a label next to your text box, and then set the .caption of the label to the localised string.

Re: GuiElement Textfield localised .text

Posted: Thu Sep 15, 2016 5:39 pm
by matjojo
aubergine18 wrote:Captions are localisable.... But textfield doesn't have a .caption.

It only has a .text property, which is the text that appears in text box.

And from what I can remember, it's not localisable (as the assumption is that the player will type stuff in there)

If you want some descriptive text, you'll need to add a label next to your text box, and then set the .caption of the label to the localised string.

welp, I'll probably use a label that gets deleted just after using the localisation on the label:

For anyone searching for this:

Code: Select all

gui.top.add{type = "label", name = "placeholder", caption = {"localisation-key"}}				--workaround for localisation not working on textfield
gui.center.add{type = "textfield", name = "name"}
gui.center.text = d.gui.top.placeholder.caption
gui.top.placeholder.destroy()
obviously these locations would not be the location you use, but this is the way I did it.

Okay, so update: This also does not work, gives the same error.

Re: GuiElement Textfield localised .text

Posted: Thu Sep 15, 2016 5:59 pm
by aubergine18
Whoa, did that work? Did you see the localised text in the textfield?

Re: GuiElement Textfield localised .text

Posted: Thu Sep 15, 2016 6:11 pm
by matjojo
aubergine18 wrote:Whoa, did that work? Did you see the localised text in the textfield?

nope, sadly it did not. added an update to the comment above

Re: GuiElement Textfield localised .text

Posted: Thu Sep 15, 2016 6:15 pm
by aubergine18
This conversation will be of interest to you: viewtopic.php?f=28&t=32611

Re: GuiElement Textfield localised .text

Posted: Thu Sep 15, 2016 8:26 pm
by matjojo
aubergine18 wrote:This conversation will be of interest to you: viewtopic.php?f=28&t=32611

I'm going to make a new feature request for this one as this one is a lot more precise and to the point.