You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tauri-plugins-workspace/examples/api/src/views/Clipboard.svelte

33 lines
724 B

<script>
import { writeText, readText } from "@tauri-apps/plugin-clipboard";
export let onMessage;
let text = "clipboard message";
function write() {
writeText(text)
.then(() => {
onMessage("Wrote to the clipboard");
})
.catch(onMessage);
}
function read() {
readText()
.then((contents) => {
onMessage(`Clipboard contents: ${contents}`);
})
.catch(onMessage);
}
</script>
<div class="flex gap-1">
<input
class="grow input"
placeholder="Text to write to the clipboard"
bind:value={text}
/>
<button class="btn" type="button" on:click={write}>Write</button>
<button class="btn" type="button" on:click={read}>Read</button>
</div>