Newline in Text Block [SOLVED]

Started by Snath3000, Sat 15/10/2011 13:59:49

Previous topic - Next topic

Snath3000

Hi all,

tl;dl: How do you do a newline character in a textbox in a gui?

I'm sorry, this sounds like a really dumb question, but I cannot for the life of me work it out.
I am trying to make a 'terminal' style gui to take input making it look like a computer monitor. I have made a custom GUI with a GUI Textbox, which I can code text in easy enough, but for some reason I can't workout how to insert a newline character.

I had a read through of the manual which says to use [, which doesn't seem to work.
It also mentions that ags uses printf style strings so I tried /n (\n and %n as well because, why not).
I tried inserting the ascii code (using String.Format("%c",asciiCode)) newline, carriage return, and form feed all to no avail, just gave me garbage characters.
I had a look through the beginners forum and couldn't seem to find anything addressing it. (But I apologise in advance if I missed something)

All these things worked fine when just doing a straight Display() function call though, so I don't believe the code I am using is in error.

Is there something obvious here that I am missing, or are TextBoxes some magical entity which require special rituals to know how to use?

Or, is it just 2am and I should be in bed by now...


Thanks,
Snath

KodiakBehr

Your title said "text block", so just to confirm, are you sure you want to go to a new line in a textbox (a box where the player inputs text) or a label (a box where the game outputs text)?

Because [ works just fine for labels.

pcj

GUI Text Boxes are activated (the function OnActivate in the text box's properties window is executed) when the user presses Enter, so I'm not sure they would be the best for multi-line text.

I would think probably the best way would be to use a Label and on_key_press to simulate what you need.  A bit more work, but it may help.
Space Quest: Vohaul Strikes Back is now available to download!

Khris

Yes, in case it isn't clear, Textboxes don't support multiple lines.

Snath3000

I had really hoped to do a combination of input and output in the same area (I'm trying to do a basic simulation of a command terminal).

I could workaround and use labels instead, but even if I were to do that, I would for my own sake like to know why newline characters and the things I tried didn't work. If only to better my understanding of the engine and how these parameters work.

Basically, my steps went thus:
I created a new gui.
Added a gui Text Box and a button to it.
Then edited function Button1_OnClick to include the code:
TextBox1.Text = String.Format("Input command prompt.[Enter username and pwd.[");

I haven't got as far as working out how to accept input yet...

pcj

New line characters don't work because text boxes don't support multi-line text.  Labels do, so the newline character "[" will work.
Space Quest: Vohaul Strikes Back is now available to download!

KodiakBehr

What you've done there is put the text "Input command prompt.  Enter username and pwd." as an input.

If you want to create a command prompt, I would suggest your GUI includes at least two things:  a label and a textbox.

The label gives you the instructions -- in this case, telling the user to enter their username and password. 
The textbox, meanwhile, is literally the place where the user will input that username and password. 
The term textbox is misleading -- textboxes are best used for inputs, while labels are best used for outputs.

Snath3000

I see, I think I get it now. Thanks. I will try having a play around with labels now and see what I can get working.

SMF spam blocked by CleanTalk