Added in API level 34

HandwritingGesture


abstract class HandwritingGesture
kotlin.Any
   ↳ android.view.inputmethod.HandwritingGesture

Base class for stylus handwriting gestures.

During a stylus handwriting session, user can perform a stylus gesture operation like SelectGesture, DeleteGesture, InsertGesture on an area of text. IME is responsible for listening to stylus MotionEvents using InputMethodService#onStylusHandwritingMotionEvent and interpret if it can translate to a gesture operation.

While creating gesture operations SelectGesture and DeleteGesture, Granularity helps pick the correct granular level of text like word level GRANULARITY_WORD, or character level GRANULARITY_CHARACTER.

Summary

Constants
static Int

Operate on text per character basis.

static Int

Operate text per word basis.

Public methods
String?

The fallback text that will be committed at current cursor position if there is no applicable text beneath the area of gesture.

Constants

GRANULARITY_CHARACTER

Added in API level 34
static val GRANULARITY_CHARACTER: Int

Operate on text per character basis. i.e. each character is selected based on its intersection with selection rectangle.

Strategy of operating at a granular level is maintained in the UI toolkit. A character/word/line is included if its center is within the gesture rectangle. e.g. if a selection RectF with GRANULARITY_CHARACTER includes width-wise center of the character, it should be selected. Similarly, text in a line should be included in the operation if rectangle includes line height center.

Value: 2

GRANULARITY_WORD

Added in API level 34
static val GRANULARITY_WORD: Int

Operate text per word basis. e.g. if selection includes width-wise center of the word, whole word is selected.

Strategy of operating at a granular level is maintained in the UI toolkit. A character/word/line is included if its center is within the gesture rectangle. e.g. if a selection RectF with GRANULARITY_WORD includes width-wise center of the word, it should be selected. Similarly, text in a line should be included in the operation if rectangle includes line height center.

Refer to https://www.unicode.org/reports/tr29/#Word_Boundaries for more detail on how word breaks are decided.
Value: 1

Public methods

getFallbackText

Added in API level 34
fun getFallbackText(): String?

The fallback text that will be committed at current cursor position if there is no applicable text beneath the area of gesture. For example, select can fail if gesture is drawn over area that has no text beneath. example 2: join can fail if the gesture is drawn over text but there is no whitespace.

Return
String? This value may be null.