Page 1 of 1

How getting the current position in a TxtCtrl ?

Posted: Mon Oct 06, 2008 7:05 pm
by Muetdhiver
Hello !

I've got a wxTextCtrl widget with an associated wxKeyEvent "OnKeyUp".

I wonder how to get the position of the cursor in the Text Control, I mean not in absolute coordinates (X and Y) but in number of lettre written.
Let's give an example:

I've got the text written to the text control:

ABCDE.
1) Thanks to the keyboard arrow, I move the cursor after the B.
2) I press backspace key
3) I want to know that the "B" has been deleted (in the OnKeyUp function event).

Obviously, the keyCode of the pressed key is "backspace". I don't know how to get the B, or maybe to get the position in the widget (in this example, the position after B is 2 if it's zero-based).

Thanks for your help.
Alexandre.

Posted: Mon Oct 06, 2008 7:12 pm
by timg
Is there some reason you can't use wxTextCtrl::GetInsertionPoint() ?

Posted: Tue Oct 07, 2008 1:04 pm
by Muetdhiver
Yes ! The reason is that i've nerver look for such a function in the wxTextCtrl documentation but in the wxKeyEvent doc!!! I'm sorry, i feel stupid not searching at the good place !
A great thanks and you won 5 wxAwards easily !!

Bye.
Alexandre.