# IME and soft keyboards

Let the input system finish a word before treating it as final. An input method editor may replace a provisional range several times while the user chooses a character or candidate. Those intermediate states are useful for display but may not be valid application data yet.

## Keep composition in the editor

`TextEditingState.MarkedRange` identifies provisional text. A native adapter uses `SetMarkedText` to update it and `UnmarkText` to finish composition. Committed `Insert` replaces the marked range when one exists. A custom validation rule should allow composition to proceed and judge the committed result instead of rejecting each provisional character.

For an experiment in ordinary C#, the following fragment exercises the editing model without claiming that every runtime forwards the same native sequence:

```csharp
var editor = new Xui.Core.UI.Input.TextEditingState();
editor.SetMarkedText("候補", new(2, 2));
// editor.MarkedRange is non-null: this is provisional text.
editor.UnmarkText();
// The accepted text remains; MarkedRange becomes null.
```

## Request useful keyboard behavior

Use `InputOptions` on `TextBox` or `TextInput`: `Keyboard` selects text, ASCII, number, or decimal hints; `ContentType` conveys a name or password hint; `ReturnAction` chooses Next or Done behavior. Set options before focusing. Hints do not constrain hardware keyboards, paste, or programmatic values.

Focusing an `ITextInputClient` makes `RequiresKeyboard` true by default. `RootView` connects the editor to an optional `ITextInputSession` and requests the software keyboard. Blur ends the session. Core fields already blur on deactivation; custom editors must manage that lifecycle.

## Check the adapter, not only the interface

| Host | Current path |
| --- | --- |
| iOS | Native range-editing bridge connects `ITextEditingClient`, marked text, and native selection behavior. |
| Android | Native input connection synchronizes text, selection, and composition with the editor. |
| Browser | A hidden textarea collects text and sends committed text after composition ends; provisional marked ranges are not mirrored into the Xui editor. |
| Windows/macOS | Current shared-field path uses key/character callbacks; the presence of the Core composition model does not establish a native range-editing session. |

The browser currently forwards committed text one UTF-16 character at a time. Exercise non-BMP characters, paste, and replacement with your actual browser and input method; do not equate this path with the native mobile editing session. Browser keyboard hints also are not fully mapped from `InputOptions`.

## Keep the field visible

A software keyboard changes usable space. Place long forms in a bounded scroller and verify the focused field remains visible during resize, rotation, and keyboard transitions. Keyboard presentation is not a guarantee of automatic scrolling to every custom editor. Desktop phone emulation cannot validate the native IME, autocorrection, or selection UI.
