Back to API Reference
Class

InputFilterBase

abstract
Inherits:InputBehavior

Base for input filters — they reject characters as they are typed (digits-only, email chars, …) by subscribing to InputFilter. A separate concern from validation (InputValidatorBase), which lets input through and judges the whole value for a visible status.

Remarks

Allows receives the full EditProposal and must judge the POST-state: text replacing a selection is acceptable whenever the resulting value is acceptable, even if the pre-state already contained the typed characters (the replaced ones are going away). Native platforms deliver multi-char strings (macOS NSString, Android CharSequence), so handle codepoints, surrogate pairs, and grapheme clusters. Same extensibility pattern as BaseModifier / ParseRule: stored via [SerializeReference, TypeSelector]; built-in and custom filters appear in the picker.

Derived Types(5)

Types that inherit from InputFilterBase.

public KeyboardType PreferredKeyboardType{ get }

Preferred mobile keyboard type. The input field uses this when no NativeKeyboardBehavior overrides it.

protected override void OnEnable()
protected override void OnDisable()
public abstract bool Allows()

Whether the proposed edit may be applied, judged on the post-state it produces. Return to drop it; the editor then discards it without firing TextChanged. Pure deletions never reach this — character filters do not block deleting.

protected static bool DocumentContains()

Returns if the document text SURVIVING the proposal (everything outside ReplacedRange) contains targetCodepoint — the post-state membership test, minus the inserted text the filter is already iterating. O(document length) per call: chunked span scans keep the constant small, but a custom filter calling this per inserted character on a multiline document is O(n) per keystroke.

protected static bool AcceptsLeadingSign()

Whether a sign char at insertedCharOffset within Inserted ends up as a single leading sign in the post-state: first inserted char, nothing surviving before it, no other sign surviving. Shared by the numeric filters.