Can't get cursor position from InputConnection

by nattster » Fri, 20 May 2011 09:30:36 GMT


Sponsored Links
 I'm developing an Input Method. 
I'd like to change cursor position with 
*InputConnection.setSelection< http://developer.android.com/reference/android/view/inputmethod/InputConnection.html #setSelection(int,
 
int)>*.

This method allows me to set absolute position of cursor.
But what I want is to move cursor relatively from current position.
(e.g. Move left 3 characters from current position)

I can't find method to get current cursor position.
Currently, I got this hack:

    InputConnection conn;
    CharSequence seq = conn.getTextBeforeCursor(1000, 0); 
    // will get as much characters as possible on the left of cursor

    int cursor_pos = seq.length();

Is there any better way to do this?
Should we introduce new method to InputConnection, i.e. getSelectionStart?

-- 



Other Threads

1. Can I release app to market which relies on a 1.1 feature?

What percentage of users are going to have 1.1 upgrade?

Don't want to be flooded by 1 star feedbacks!!!
--~--~---------~--~----~------------~-------~--~----~

2. help maps

Hello i have a problem with the visualization of map, i have follow
the tutorial of  MapView  but i don't see the map i have insert api
key but nothing where is the problem?

Please help me.....thanks
--~--~---------~--~----~------------~-------~--~----~

3. Dalvik on glibc

4. deploying same application twice different content

5. video demo : nitdroid on emulated n8x0 (qemu running android on nokia tablets)

6. I must pay 25$ to distribute a FREEWARE on Android Market

7. Ringtone picker -- how to get return value from EXTRA_RINGTONE_PICKED_URI