ClipboardManager


Interface for managing the Clipboard.

Summary

Public functions

open ClipEntry?

Returns the primary clipboard entry that's provided by the platform's ClipboardManager.

Cmn
open ClipMetadata?

Returns a ClipMetadata which describes the primary clip entry.

Cmn
AnnotatedString?

This method get the text from the Clipboard.

Cmn
open Boolean

Returns true if there is currently a primary clip on the platform Clipboard.

Cmn
open Boolean

This method returns true if there is a text in the Clipboard, false otherwise.

Cmn
open Unit
setClip(clipEntry: ClipEntry)

Puts the given clipEntry in platform's ClipboardManager.

Cmn
Unit
setText(annotatedString: AnnotatedString)

This method put the text into the Clipboard.

Cmn

Public properties

open NativeClipboard

Returns the native clipboard that exposes the full functionality of platform clipboard.

Cmn

Public functions

getClip

open fun getClip(): ClipEntry?

Returns the primary clipboard entry that's provided by the platform's ClipboardManager. This item can include arbitrary content like images, videos, or any data that may be provided through a mediator. Returned entry may contain multiple items with different types.

Calling this method may show a Clipboard access warning message to the user on mobile platforms since it usually accesses the Clipboard contents.

getClipMetadata

open fun getClipMetadata(): ClipMetadata?

Returns a ClipMetadata which describes the primary clip entry. This is an ideal way to check whether to accept or reject what may be pasted from the clipboard without explicitly reading the content.

Calling this function does not trigger any content access warnings on any platform.

getText

fun getText(): AnnotatedString?

This method get the text from the Clipboard.

Returns
AnnotatedString?

The text in the Clipboard. It could be null due to 2 reasons: 1. Clipboard is empty; 2. Cannot convert the CharSequence text in Clipboard to AnnotatedString.

hasClip

open fun hasClip(): Boolean

Returns true if there is currently a primary clip on the platform Clipboard. Even though getClip should be available immediately, getClipMetadata may still return null if the platform doesn't support clip descriptions.

hasText

open fun hasText(): Boolean

This method returns true if there is a text in the Clipboard, false otherwise.

setClip

open fun setClip(clipEntry: ClipEntry): Unit

Puts the given clipEntry in platform's ClipboardManager.

Parameters
clipEntry: ClipEntry

Platform specific clip object that either holds data or links to it.

setText

fun setText(annotatedString: AnnotatedString): Unit

This method put the text into the Clipboard.

Parameters
annotatedString: AnnotatedString

The AnnotatedString to be put into Clipboard.

Public properties

nativeClipboard

open val nativeClipboardNativeClipboard

Returns the native clipboard that exposes the full functionality of platform clipboard.

Throws
kotlin.UnsupportedOperationException

If the current platform does not offer a native Clipboard interface.