TextCtrl GetInsertionPoint and GetValue Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Earned a small fee
Earned a small fee
Posts: 14
Joined: Wed Jan 24, 2018 4:39 pm

TextCtrl GetInsertionPoint and GetValue

Post by gmapp » Wed Jan 24, 2018 5:08 pm

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

User avatar
Posts: 15174
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: TextCtrl GetInsertionPoint and GetValue

Post by doublemax » Wed Jan 24, 2018 5:17 pm


Read the paragraph "wxTextCtrl Text Format" (near the top).
Use the source, Luke!

Post Reply