Home | Reviews | GUIpedia | Forum | Fun500
Brandon | Multiline inputDoes anyone have a good multi-line input routine? I tried to start one but its hard, especially for a good one. | 2008-10-11 | 12:50 PM |
ksr | Re:Multiline inputBy 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-11 | 1:34 PM |
Brandon | Re:Multiline inputYeah, all of that is easier said than done. | 2008-10-11 | 1:52 PM |
ksr | Re:Multiline inputYeah, true. I'd implement one but I haven't got enough of the GUI working yet. | 2008-10-11 | 2:23 PM |
Brandon | Re:Multiline inputHeck I didn't really make my regular input routine, it was Jacob's, and has been modified over and over. | 2008-10-11 | 2:27 PM |
GUIs
2021 Brandon Cornell