Skip to content

Commit

Permalink
Fix issue where web clipboard crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jan 7, 2025
1 parent dd0f794 commit 20efe1c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/driver/glfw/clipboard_goxjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ package glfw

import (
"fyne.io/fyne/v2"
glfw "github.com/fyne-io/glfw-js"
)

// Declare conformity with Clipboard interface
var _ fyne.Clipboard = (*clipboard)(nil)

// clipboard represents the system clipboard
type clipboard struct {
window *glfw.Window
}

// Content returns the clipboard content
func (c *clipboard) Content() string {
content := ""
runOnMain(func() {
content, _ = c.window.GetClipboardString()
win := fyne.CurrentApp().Driver().AllWindows()[0].(*window).viewport
content, _ = win.GetClipboardString()
})
return content
}

// SetContent sets the clipboard content
func (c *clipboard) SetContent(content string) {
runOnMain(func() {
c.window.SetClipboardString(content)
win := fyne.CurrentApp().Driver().AllWindows()[0].(*window).viewport
win.SetClipboardString(content)
})
}

0 comments on commit 20efe1c

Please sign in to comment.