Textarea and SetTextArea
BlitzMax Forums/MaxGUI Module/Textarea and SetTextArea
| ||
Hi before I start to hammer my computer I decided to post here this piece of code so maybe someone smarter than me can found where is the error! Basically it is a simple textarea. If you type something like this (just start a line with Global, Local or Field) Local a,b,c>>Int Local a1,a2,a3>># the textarea should rewrite the line in a 'extended' way like Local a:Int, b:int, c:int Local a1#,a2#,a3# The function to strip/replace data-types seems to work, I have problems only with the SetTextAreaText function (...) Can anyone give me an hand please? |
| ||
This works but might not be what you're after? -> Press the change button! Grisu |
| ||
Hi So your solution is to rebuild all the content... I don't know if with a big text this could be a speed limit. In any case thanks for your help! Ps... Maybe lock text area could do the job... I really don't understand why in basic example everything works as expected! |
| ||
Locktextarea() helps a lot when dealing with large amounts of text. So you want the line to be formatted directly after the user has pressed "Enter"? How much text we are speaking of here? |
| ||
The idea is to change only the LAST line typed by the user. So there's no much text at all (in one line of course). But consider this should be a change in MaxIDE, so the text could be thousands of lines... I noticed that the line is 'truncated' at the previous typed length... Local a,b,c>>Int (has 16 characters) RESULTS Local a:Int,b:In t,c:Int If I try to change (without my function) with a standard SetTextAreaText everythink works as expected. It seems MaxGUI/my function 'remembers' where is the last 'newline' character EDIT: I changed my function to remove new line characters... but no luck. |
| ||
Still here trying to resolve the problem... Stupid example - working as expected. If you type in the textarea it will change in UPPERCASE (set > SET) and so on. No line break, no errors. Ok, try to uncomment the second 'nline' (nline=text+"__test") It should add __test to any line typed. But in my case any line is 'broken' like below set set __test I tried to 'trim()' the string, to check if there are any strange ASCII code in the line (ie: 10), but nothing - only normal characters. It's like textarea remembers that after SET (in the example) there is a CR/LF... Any idea how to resolve this? Thanks |
| ||
Hello degac, problem is the ENTER-key processed by the control it self and inserting newline character in the wrong place (where cursor is and not at the end of the line). One solution is to move the cursor yourself like: Function Change2:Int(context:Object) Local pos_cursor:Int, pos_line:Int pos_cursor = TextAreaCursor(textarea) pos_line = TextAreaLine(textarea,pos_cursor) Local text:String = TextAreaText(textarea,pos_line,1,TEXTAREA_LINES)'.Trim() Local nline:String, size:Int nline=text.toupper() + "__test" SetTextAreaText(textarea, nline, pos_line, 1, TEXTAREA_LINES) SelectTextAreaText(textarea, pos_line + 1, 0, TEXTAREA_LINES) End Function -Henri |
| ||
Ohhh! THANK YOU! I never looked at the Filter function... I still don't understand the nature of the problem, as the returned line 'seems' a full line... In any case, Thank you again! |
| ||
It is my understanding that the SetAreaText does not automatically move the cursor, so when you are setting text that is longer, the cursor remains a bit behind. Then the native callback function (not your filter function) of the textareagadget inserts newline (because user pressed enter) where the cursor is resulting unexpected behaviour. PS. AddTextAreaText moves the cursor automatically. -Henri |
| ||
Ah.. Ok thanks for the explanation |