The 2D layer · function

applyComposition

Fold one composition update into the model.

Explained in Sprites and tilemaps.

function applyComposition(model: TextModel, state:
import { applyComposition } from '@driftengine/ui2d';

Parameters

ParameterTypeDescription
modelTextModel
state{ text: string; done: boolean; }

In depth

An update replaces whatever the previous update of this composition put there, rather than the whole field — which is what makes a five-keystroke entry produce one word instead of five.

done clears the range, and that is the step everyone forgets. A finished composition that leaves its range set means the next keystroke overwrites the text that was just committed, which presents as characters vanishing one word behind the caret.