mcbopomofoweb
    Preparing search index...

    Controller class that manages the input method's state and handles keyboard events. This class serves as the main coordinator between different components of the input method, including the UI, language model, and keyboard handler.

    The controller is responsible for:

    • Managing input states (empty, inputting, choosing candidates, etc.)
    • Handling keyboard events and routing them to appropriate handlers
    • Managing candidate selection and display
    • Coordinating between the UI and the language model
    • Handling various input method configurations

    Key features:

    • Supports multiple keyboard layouts (Standard, ETen, Hsu, etc.)
    • Handles both traditional and simplified Chinese input
    • Supports customizable candidate key selection
    • Manages vertical and horizontal candidate window layouts
    • Handles various input states and transitions
    • Supports user phrases and dictionary lookups
    const ui = new InputUI();
    const controller = new InputController(ui);
    controller.setKeyboardLayout("Standard");
    controller.setTraditionalMode(true);
    Index

    Constructors

    Accessors

    Methods

    • Handles the passed keyboard events.

      Parameters

      • event: KeyboardEvent

        The keyboard event.

      Returns boolean

      If the key is handled.

    • Sets the candidate keys

      Parameters

      • keys: string

        The candidate keys, such "123456789".

      Returns void

    • Sets the number of candidate selection keys.

      Parameters

      • count: number

        The number of candidate selection keys to set. Must be between 4 and 15 inclusive.

      Returns void

    • Sets if the ESC key should clear the entire composing buffer.

      Parameters

      • flag: boolean

        If the ESC key should clear the entire composing buffer.

      Returns void

    • Sets if we want to use half width punctuation.

      Parameters

      • enabled: boolean

        Use half width punctuation.

      Returns void

    • Sets keyboard layout.

      Parameters

      • layout: string

        Keyboard layout. It could be:

        • "Standard"
        • "ETen"
        • "Hsu"
        • "ETen26"
        • "HanyuPinyin"
        • "IBM"

      Returns void

    • The language code for localized messages.

      Parameters

      • languageCode: string

        The language code.

      Returns void

    • Ser if the input method should input uppercase or lowercase letters when users type shift and letter keys.

      Parameters

      • letterCase: string

        "lower" or "upper".

      Returns void

    • Sets if the input method should move cursor after selecting a candidate.

      Parameters

      • flag: boolean

        To enable the function or not.

      Returns void

    • Sets the error handler function for the input controller.

      Parameters

      • onError: Function

        The callback function to handle errors

      Returns void

    • Help the controller to open a URL.

      Parameters

      • input: undefined | ((input: string) => void)

      Returns void

    • Sets the callback function that would be called when the a user phrase model is added.

      Parameters

      • callback: (key: string, phrase: string) => void

        The callback function.

      Returns void

    • Sets the callback function that would be called when the user phrase model is changed.

      Parameters

      • callback: (map: Map<string, string[]>) => void

        The callback function.

      Returns void

    • Enables or disables the feature that allows repeated punctuation to select a candidate.

      Parameters

      • flag: boolean

        A boolean value indicating whether the feature should be enabled (true) or disabled (false).

      Returns void

    • Sets if we should select the candidate before the cursor or after the cursor.

      Parameters

      • option: string

        "after_cursor" or "before_cursor".

      Returns void

    • Sets if the input controller should use traditional mode or not.

      Parameters

      • flag: boolean

      Returns void

    • Sets whether to enable cursor movement using 'J' and 'K' keys when the candidate window is visible. When enabled, users can navigate through candidates using these keys similar to vim-style navigation.

      Parameters

      • flag: boolean

        True to enable J/K cursor movement, false to disable

      Returns void

    • Sets the user phrases to the language model.

      Parameters

      • input: string | Map<string, string[]>

        The map of user phrases.

      Returns void

    • Sets if we want to use vertical or horizontal candidate window.

      Parameters

      • flag: boolean

        Use the vertical candidate window.

      Returns void