in hot-reload-devtools/src/main/kotlin/org/jetbrains/compose/devtools/widgets/DtCopyToClipboardButton.kt [24:48]
fun DtCopyToClipboardButton(
modifier: Modifier = Modifier,
content: () -> String,
) {
val clipboard = LocalClipboard.current
var copyAll by remember { mutableStateOf(false) }
LaunchedEffect(copyAll) {
if (copyAll) {
clipboard.setClipEntry(ClipEntry(StringSelection(content())))
copyAll = false
}
}
DtIconButton(
onClick = { copyAll = true },
modifier = modifier,
tag = Tag.CopyToClipboardButton,
tooltip = "Copy to clipboard",
) {
DtImage(
image = DtImages.Image.COPY_ICON,
tint = Color.White,
)
}
}