Hi Jakob,

On 02.01.2007 10:24, Jakob Lechner wrote:

I need to determine the word at the current (mouse) cursor position. The
code below computes the index of the letter at the current cursor
position:

<snip>

But if a text field is underneath the cursor the returned index is
always the position of the whole field. How can I compute the index of
the letter of the text inside the field?

we once had the same problem when we were implementing some accessibility functionality. Therefore we added a pointer SwSpecialPos* pSpecialPos to the SwCrsrMoveState struct.

Change your code to use the SwSpecialPos stuff:

SwCrsrMoveState aTmpState( MV_SETONLYTEXT );
SwSpecialPos aSpecialPos;
aTmpState.pSpecialPos = &aSpecialPos;
GetLayout()->GetCrsrOfst( &aPos, aPt, &aTmpState )

After the call to GetCrsrOfst() aSpecialPos should contain the correct offset.

Hope this helps,

Frank

--
Sun Microsystems GmbH      Frank Meies
http://www.sun.de          mailto:[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  • [sw-discussion... Jakob Lechner
    • Re: [sw-d... Frank Meies - Sun Germany - Development - Software Engineer
      • Re: [... Jakob Lechner
        • R... Frank Meies - Sun Germany - Development - Software Engineer

Reply via email to