-
Notifications
You must be signed in to change notification settings - Fork 2
clipboard read text
github-actions[bot] edited this page Jun 2, 2026
·
1 revision
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import com.mobilebytelabs.kmptoolkit.clipboard.Clipboard
import kotlinx.coroutines.launch
@Composable
fun PasteIntoFieldButton(onPasted: (String) -> Unit) {
val scope = rememberCoroutineScope()
Button(onClick = {
scope.launch {
Clipboard.read()?.let(onPasted)
}
}) { Text("Paste") }
}- iOS 14+: a paste action surfaces a system toast "{App} pasted from {SourceApp}" — Apple's privacy policy, not bypassable.
- Android 12+: the OS shows a paste-notification toast for the same reason. For privacy compliance, only read the clipboard in direct response to a user-initiated action (e.g. button click), never on app foreground.
- JS / wasmJs: browsers require the page to be in focus AND a user-gesture handler; some browsers prompt the user for permission on first read.
-
JVM Desktop:
Toolkit.getSystemClipboard(); on Linux, also triesxclip -selection clipboard -ofor non-AWT environments.
- Module: cmp-clipboard
- Sample:
samples/sample-cmp-clipboard/composeApp/.../PasteDemo.kt - See also: Copy text to the system clipboard
** Partials**
App Intents
Bubble
Clipboard
Cookbook
- Clipboard Copy Text
- Clipboard Read Text
- Consumer Anon Key Setup
- Crashlytics Attribution Per Library
- Ifonline Block
- Index
- Index
- Index
- Index
- Open Url Compose
- Pick And Share Image
- React To Offline
- Register Firebase Hooks
- Share Pdf Android
- Share Text
- Wifi Vs Cellular
Firebase Analytics
In App Update
Intent Launcher
Inter App Comms
Modules
- Cmp App Intents
- Cmp App Intents Compose
- Cmp Bubble
- Cmp Clipboard
- Cmp Deep Link
- Cmp Firebase Analytics
- Cmp In App Update
- Cmp Intent Launcher
- Cmp Intent Launcher Compose
- Cmp Library
- Cmp Network Monitor
- Cmp Network Monitor Compose
- Cmp Observe
- Cmp Observe Koin
- Cmp Open Url
- Cmp Pdf Generator
- Cmp Product Tickets
- Cmp Remote Config
- Cmp Share
- Cmp Share Compose
- Cmp Toast
Network Monitor
Open Url
Pdf Generator
Remote Config
Share
Toast
User Tickets
General