GuiElement Textfield localised .text

Place to get help with not working mods / modding interface.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

GuiElement Textfield localised .text

Post 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?
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: GuiElement Textfield localised .text

Post 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.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: GuiElement Textfield localised .text

Post 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.
Last edited by matjojo on Thu Sep 15, 2016 6:10 pm, edited 1 time in total.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: GuiElement Textfield localised .text

Post by aubergine18 »

Whoa, did that work? Did you see the localised text in the textfield?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: GuiElement Textfield localised .text

Post 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
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: GuiElement Textfield localised .text

Post by aubergine18 »

This conversation will be of interest to you: viewtopic.php?f=28&t=32611
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
matjojo
Filter Inserter
Filter Inserter
Posts: 338
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: GuiElement Textfield localised .text

Post 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.
Post Reply

Return to “Modding help”