How getting the current position in a TxtCtrl ? 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
Muetdhiver
Super wx Problem Solver
Super wx Problem Solver
Posts: 323
Joined: Sun Jun 08, 2008 11:59 am
Location: Bordeaux, France

How getting the current position in a TxtCtrl ?

Post by Muetdhiver » Mon Oct 06, 2008 7:05 pm

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.

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Mon Oct 06, 2008 7:12 pm

Is there some reason you can't use wxTextCtrl::GetInsertionPoint() ?

Muetdhiver
Super wx Problem Solver
Super wx Problem Solver
Posts: 323
Joined: Sun Jun 08, 2008 11:59 am
Location: Bordeaux, France

Post by Muetdhiver » Tue Oct 07, 2008 1:04 pm

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.

Post Reply