Page 1 of 1

TextCtrl GetInsertionPoint and GetValue

Posted: Wed Jan 24, 2018 5:08 pm
by gmapp
Dear all,
I have a problem with a multiline TextCtrl.
In an empty box of my app, if I write: "abcd<newline>abcd" and then I get the length of content of the text box and the cursor position, the two values are not the same. In my case, I aspect '9' for the length of the string and '9' also for the cursor position (or 10 for both).

Code: Select all

long int pos = TextCtrl1->GetInsertionPoint();
long int size = TextCtrl1->GetValue().size();
but size=9 and pos=10.
I'm on Windows, so probably when a press the return for a new line, in the text box are inserted two char: "\r\n". Does GetValue() strip the \r?

I want to get the content of the text box and run some substitutions dependent on the position of the current InsertionPoint...

Have someone some idea how to manage the problem?

Many thanks

Re: TextCtrl GetInsertionPoint and GetValue

Posted: Wed Jan 24, 2018 5:17 pm
by doublemax
http://docs.wxwidgets.org/trunk/classwx_text_ctrl.html

Read the paragraph "wxTextCtrl Text Format" (near the top).