jQrgen
03/05/2026, 1:08 PMLocalClipboardManager.current is marked as deprecated, but when I try to use LocalClipboard.current there is no way to set the clipboard text?
I try to do:
val clipboard = LocalClipboard.current
And then:
rememberCoroutineScope().launch {
clipboard.setClipEntry(<What to put here?>)
}
setClipEntry(..) wants a ClipEntry object But the class ClipEntry from jetbrains compose UI package has no constructor?
/** Platform specific protocol that expresses an item in the native Clipboard. */
expect class ClipEntry {
/**
* Returns a [ClipMetadata] which describes the contents of this [ClipEntry]. 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.
*/
val clipMetadata: ClipMetadata
}
So JetBrains has deprecated a package and told me to use another package that does not work? Or am I misunderstanding something here?Jonas
03/05/2026, 1:23 PMval clipboard = LocalClipboard.current
...
clipboard.setClipEntry(clipEntryOf(txt))
expect fun clipEntryOf(string: String): ClipEntry
//ios
@OptIn(ExperimentalComposeUiApi::class)
actual fun clipEntryOf(string: String) = ClipEntry.withPlainText(string)
//jvm
@OptIn(ExperimentalComposeUiApi::class)
actual fun clipEntryOf(string: String) = ClipEntry(StringSelection(string))
//wasm
actual fun clipEntryOf(string: String) = ClipEntry.withPlainText(string)
//android
actual fun clipEntryOf(string: String) = ClipData.newPlainText(null, string).toClipEntry()jQrgen
03/05/2026, 1:36 PMIvan Matkov
03/05/2026, 3:07 PM