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. [libgdx]texture animation flickers

Hi, guys.

  I am using libgdx...and experiencing the flickering problem..

  Situation: I try to render an animation which has 3 frames in one
sprite sheet.After i upload and run this on my HERO, the flickering
problem occurs.

<code>
                mElapsedTime += Gdx.graphics.getDeltaTime();


                if (mElapsedTime > 0.3f) {
                        TextureRegion region = 
mTextureRegions.get(mTextureRegionIndex);
                        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

                        SpriteBatch batch = mBatch;
                        batch.begin();
                        batch.draw(region.texture, 100f, 100f, region.x, 
region.y,
region.width, region.height, Color.RED);
                        batch.end();


                        mElapsedTime = 0f;
                        mTextureRegionIndex = ++mTextureRegionIndex % 3;
                }
</code>

I searched around and found

2. Is possible to debug OpenGL ES 2.0 application on Emulator?

Hi all,
I'm new in this group (and new as android developer). A question: is
it possible to debug OpenGL ES 2.0 applications on emulator or I need
a real target? Using emulator could be useful to test the same
application with different Android APIs.

Regards.

-- 

3. Mobile Application Development in Openwave Computing !

4. SIpdroid and Trixbox over LAN?

5. Bug report, why it need more permissions?

6. set it up!

7. Android Life Cycle