Home | Reviews | GUIpedia | Forum | Fun500


BrandonMultiline input
Does anyone have a good multi-line input routine? I tried to start one but its hard, especially for a good one.
2008-10-1112:50 PM

ksrRe:Multiline input
By multi-line, do you mean like an HTML text-area? How you implement it depends entirely on how your GUI works, but it shouldn't be [i]too[/i] hard in any case. Start by treating the contents as a single string. When displaying the text, add on a character (or word, up to you) at a time and stop before the max width is exceeded. Then move to the next line and carry on. You need a variable to store the position of the text cursor. When the text-area is clicked, you need to work out what position in the text string has been clicked (this is obviously easier with fixed-width fonts, but many variable-width fonts have a function which returns the pixel length of a given string that you can work with). Then when you type you are inserting text into the string at the position of the cursor (whilst incrementing it, of course). When you can click to change the cursor position, highlighting text shouldn't be too hard either.
2008-10-111:34 PM

BrandonRe:Multiline input
Yeah, all of that is easier said than done.
2008-10-111:52 PM

ksrRe:Multiline input
Yeah, true. I'd implement one but I haven't got enough of the GUI working yet.
2008-10-112:23 PM

BrandonRe:Multiline input
Heck I didn't really make my regular input routine, it was Jacob's, and has been modified over and over.
2008-10-112:27 PM

GUIs


2021 Brandon Cornell