How to get the caret position within the wx.TextCtrl?


thanks for the answer.

I have alredy tried to solve it with the GetInsertionPoint() method. I think it is not possible to do it this way.
You get number of columns and rows. You would have to get the size of the font + size of the window decoration

to get the actual position of the caret. (all I know is to get height of the font. I have no idea, how would I figure out the rest)

anyway, I finally solved my problem. One must use the StyledTextCtrl.
I used the GetCurrentPos() and PointFromPosition() methods.

I assume, it is not possible to get the exact caret position in pixels in simple TextCtrl.

-jan bodnar
 

<snipped>

GetCaret is misleadingly named (it'll return a wxCaret object on some

platforms). What you want is GetInsertionPoint(), combined with
PositionToXY().

The other method I mentioned, PositionToXY, will translate a
column/row coordinate into pixels.

···

On 1/6/07, vronskij <vronskij@gmail.com> wrote:

thanks for the answer.

I have alredy tried to solve it with the GetInsertionPoint() method. I think
it is not possible to do it this way.
You get number of columns and rows. You would have to get the size of the
font + size of the window decoration

to get the actual position of the caret. (all I know is to get height of the
font. I have no idea, how would I figure out the rest)

anyway, I finally solved my problem. One must use the StyledTextCtrl.
I used the GetCurrentPos() and PointFromPosition() methods.

I assume, it is not possible to get the exact caret position in pixels in
simple TextCtrl.

Never mind, I'm totally wrong. I need to read better and test better
to make sure I see what I think I'm seeing.

···

On 1/8/07, Chris Mellon <arkanes@gmail.com> wrote:

On 1/6/07, vronskij <vronskij@gmail.com> wrote:
>
> thanks for the answer.
>
> I have alredy tried to solve it with the GetInsertionPoint() method. I think
> it is not possible to do it this way.
> You get number of columns and rows. You would have to get the size of the
> font + size of the window decoration
>
> to get the actual position of the caret. (all I know is to get height of the
> font. I have no idea, how would I figure out the rest)
>
> anyway, I finally solved my problem. One must use the StyledTextCtrl.
> I used the GetCurrentPos() and PointFromPosition() methods.
>
> I assume, it is not possible to get the exact caret position in pixels in
> simple TextCtrl.
>

The other method I mentioned, PositionToXY, will translate a
column/row coordinate into pixels.