Clipboard

This commit is contained in:
Theoo3 2020-09-12 10:56:39 -07:00
parent 88b1e1c2d3
commit 7027267cbf
2 changed files with 21 additions and 5 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.12
require (
github.com/faiface/glhf v0.0.0-20181018222622-82a6317ac380
github.com/faiface/mainthread v0.0.0-20171120011319-8b78f0a41ae3
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 // indirect
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72
github.com/go-gl/mathgl v0.0.0-20190416160123-c4601bc793c7
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0

View File

@ -405,10 +405,10 @@ func (w *Window) SetCursorVisible(visible bool) {
// SetCursorDisabled hides the cursor and provides unlimited virtual cursor movement
// make cursor visible using SetCursorVisible
func (w *Window) SetCursorDisabled() {
w.cursorVisible = false
mainthread.Call(func() {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
})
w.cursorVisible = false
mainthread.Call(func() {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorDisabled)
})
}
// CursorVisible returns the visibility status of the mouse cursor.
@ -494,3 +494,19 @@ func (w *Window) Show() {
w.window.Show()
})
}
// Clipboard returns the contents of the system clipboard.
func (w *Window) Clipboard() string {
var clipboard string
mainthread.Call(func() {
clipboard = w.window.GetClipboardString()
})
return clipboard
}
// SetClipboardString sets the system clipboard to the specified UTF-8 encoded string.
func (w *Window) SetClipboard(str string) {
mainthread.Call(func() {
w.window.SetClipboardString(str)
})
}