I'm attempting to work out how BaseInputConnection works using the
SpannableStringBuilder as the Editable and have this code:

public class MyInputConnection extends BaseInputConnection {

        private static final String DEBUG_TEST = new String("ABCDEF");
        private SpannableStringBuilder mEditable;

        public CrosswordInputConnection(View targetView, boolean fullEditor)
{
                super(targetView, fullEditor);
        }

        public Editable getEditable() {
        if (mEditable == null) {
            mEditable = (SpannableStringBuilder)
Editable.Factory.getInstance().newEditable(DEBUG_TEST);
            }
        return mEditable;
    }

        public boolean commitText(CharSequence text, int newCursorPosition) {
                mEditable.append(text);
                return true;
        }

        public ExtractedText getExtractedText(ExtractedTextRequest request,
int flags) {
                ExtractedText ext = new ExtractedText();
                ext.text = mEditable.toString();
                return ext;
        }
}

What I'm having trouble understanding is where the cursor is set in
the Editable/SpannableStringBuilder.  The mEditable.mText member
contains 'ABCDEF' (as per the getEditable call).  When the soft
keyboard pops up, and I press 'x' this breaks into the commitText()
method above.  The mEditable.append(text) (of the 'x' char) applies
the 'x' to mEditable.mText[0], rather than at the end (which is what
one would expect with an append() call).  So, clearly I'm missing
something here with regards to the placement of a cursor or somesuch
within the Editable object.  I'd appreciate a push in the right
direction.
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to