TextToolbar

Interface

Common
@JvmDefaultWithCompatibility
interface TextToolbar

Interface for text-related toolbar.

Properties

Common
val status: TextToolbarStatus

Return the TextToolbarStatus to check if the toolbar is shown or hidden.

Returns

TextToolbarStatus of TextToolbar.

Functions

fun showMenu(
        rect: Rect,
        onCopyRequested: (() -> Unit)? = null,
        onPasteRequested: (() -> Unit)? = null,
        onCutRequested: (() -> Unit)? = null,
        onSelectAllRequested: (() -> Unit)? = null,
        onAutofillRequested: (() -> Unit)? = null,
    )

Show the floating toolbar(post-M) or primary toolbar(pre-M) for copying, cutting and pasting text.

Parameters

rectregion of interest. The selected region around which the floating toolbar should show. This rect is in global coordinates system.
onCopyRequestedcallback to copy text into ClipBoardManager. If null, the copy option will not be shown.
onPasteRequestedcallback to get text from ClipBoardManager and paste it. If null, the paste option will not be shown.
onCutRequestedcallback to cut text and copy the text into ClipBoardManager. If null, the cut option will not be shown.
onSelectAllRequestedcallback to select all the text content. If null, the select all option will not be shown.
onAutofillRequestedcallback to autofill the field. If null, the autofill option will not be shown.
fun showMenu(
        rect: Rect,
        onCopyRequested: (() -> Unit)? = null,
        onPasteRequested: (() -> Unit)? = null,
        onCutRequested: (() -> Unit)? = null,
        onSelectAllRequested: (() -> Unit)? = null,
    )

Show the floating toolbar(post-M) or primary toolbar(pre-M) for copying, cutting and pasting text.

Parameters

rectregion of interest. The selected region around which the floating toolbar should show. This rect is in global coordinates system.
onCopyRequestedcallback to copy text into ClipBoardManager. If null, the copy option will not be shown.
onPasteRequestedcallback to get text from ClipBoardManager and paste it. If null, the paste option will not be shown.
onCutRequestedcallback to cut text and copy the text into ClipBoardManager. If null, the cut option will not be shown.
onSelectAllRequestedcallback to select all the text content. If null, the select all option will not be shown.
fun hide()

Hide the floating toolbar(post-M) or primary toolbar(pre-M).