Taal

IInputConnectionExtensions.SetComposingText Method

Definition

Overloads

Name Description
SetComposingText(IInputConnection, String, Int32)

Replace the currently composing text with the given text, and set the new cursor position.

SetComposingText(IInputConnection, String, Int32, TextAttribute)

Sets composing text with additional text attributes.

SetComposingText(IInputConnection, String, Int32)

Replace the currently composing text with the given text, and set the new cursor position.

public static bool SetComposingText(this Android.Views.InputMethods.IInputConnection self, string? text, int newCursorPosition);
static member SetComposingText : Android.Views.InputMethods.IInputConnection * string * int -> bool

Parameters

self
IInputConnection

The input connection on which to call the method.

text
String

The composing text. The default style for composing text is used.

newCursorPosition
Int32

The new cursor position around the text. If > 0, this is relative to the end of the text - 1; if <= 0, this is relative to the start of the text. So a value of 1 will always advance you to the position after the full text being inserted. Note that this means you can't position the cursor within the text, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there.

Returns

The value returned by the input connection's character sequence overload.

Remarks

Replace the currently composing text with the given text, and set the new cursor position. Any composing text set previously will be removed automatically.

If there is any composing span currently active, all characters that it comprises are removed. The passed text is added in its place, and a composing span is added to this text. If there is no composing span active, the passed text is added at the cursor position (removing selected characters first if any), and a composing span is added on the new text. Finally, the cursor is moved to the location specified by newCursorPosition.

Input methods usually call this method to add, remove, or change characters in the composing span. The editor calls OnUpdateSelection(Int32, Int32, Int32, Int32, Int32, Int32) on the current input method after the batch edit is over.

Editor authors: the text can be similar to or different from the current composing text, and there may be no composing span. An empty string replaces the composing text with empty text. Handle the cursor position as specified; input methods rely on it. Report the changes with UpdateSelection(View, Int32, Int32, Int32, Int32), waiting until any batch edit is over. This method can set the cursor at either edge of the composing text or outside it. A later call can also move the cursor within the composing text; the composing text and selection are independent.

Android reference for android.view.inputmethod.InputConnection.setComposingText.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SetComposingText(IInputConnection, String, Int32, TextAttribute)

Sets composing text with additional text attributes.

public static bool SetComposingText(this Android.Views.InputMethods.IInputConnection self, string text, int newCursorPosition, Android.Views.InputMethods.TextAttribute? textAttribute);
static member SetComposingText : Android.Views.InputMethods.IInputConnection * string * int * Android.Views.InputMethods.TextAttribute -> bool

Parameters

self
IInputConnection

The input connection on which to call the method.

text
String

The composing text. The default style for composing text is used. This value cannot be null.

newCursorPosition
Int32

The new cursor position around the text. If > 0, this is relative to the end of the text - 1; if <= 0, this is relative to the start of the text. So a value of 1 will always advance you to the position after the full text being inserted. Note that this means you can't position the cursor within the text, because the editor can make modifications to the text you are providing so it is not possible to correctly specify locations there.

textAttribute
TextAttribute

The extra information about the text. This value may be null.

Returns

The value returned by the input connection's character sequence overload.

Remarks

This variant of SetComposingText(IInputConnection, String, Int32) lets the input method provide extra information about the composing text.

Android reference for android.view.inputmethod.InputConnection.setComposingText.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to