clipboard_goxjs.go 676 B

123456789101112131415161718192021222324252627282930313233
  1. //go:build js || wasm || test_web_driver
  2. // +build js wasm test_web_driver
  3. package glfw
  4. import (
  5. "fyne.io/fyne/v2"
  6. glfw "github.com/fyne-io/glfw-js"
  7. )
  8. // Declare conformity with Clipboard interface
  9. var _ fyne.Clipboard = (*clipboard)(nil)
  10. // clipboard represents the system clipboard
  11. type clipboard struct {
  12. window *glfw.Window
  13. }
  14. // Content returns the clipboard content
  15. func (c *clipboard) Content() string {
  16. content := ""
  17. runOnMain(func() {
  18. content, _ = c.window.GetClipboardString()
  19. })
  20. return content
  21. }
  22. // SetContent sets the clipboard content
  23. func (c *clipboard) SetContent(content string) {
  24. runOnMain(func() {
  25. c.window.SetClipboardString(content)
  26. })
  27. }