This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
thenextntnick's profile picture

Basic text field?

Started by thenextntnick, 16 June 2015 - 03:53 PM
thenextntnick #1
Posted 16 June 2015 - 05:53 PM
Any of you guys know how to make a basic text field? read() dosen't work out quite well…
The Crazy Phoenix #2
Posted 16 June 2015 - 06:04 PM
For that, I'm afraid you might have to make your own "read" function, since that one might not allow you to. You could try redirecting the terminal to a window whose borders match that of the text field and run the "read" function. However, I don't think you can avoid writing a new function for multiline text fields. You should probably take a look at the edit program (/rom/programs/edit) if you need a functional example.
Square789 #3
Posted 16 June 2015 - 06:28 PM
That would be complex. You'd need line-shifting, and a typing/rendering engine, where line-shifting would be the hardest part.
You can show us some code if you got any so far, then we can help you.
Creator #4
Posted 16 June 2015 - 09:47 PM
Really look at the edit program. It might help.
Dog #5
Posted 16 June 2015 - 11:47 PM
thenextntnick,

What are you trying to do? Why doesn't read() do what you want? What you need could be very simple or quite complex, but without more information all we can do is guess at what you're trying to accomplish.

If you're trying to make a text field that allows for multiple lines and arrow navigation, etc. then the above recommendations are pretty spot on. If you're just looking for a way to allow users to input simple data or answers to questions, that's a fair bit easier.

Let us know what you want and please post any code you've already written so we can help you out further.