From 7027267cbfcc8a52ac22f697c7d7589a004acd5f Mon Sep 17 00:00:00 2001 From: Theoo3 Date: Sat, 12 Sep 2020 10:56:39 -0700 Subject: [PATCH 1/2] Clipboard --- go.mod | 2 +- pixelgl/window.go | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index dc9ce1c..10281bf 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/pixelgl/window.go b/pixelgl/window.go index af1f1a7..f237c0b 100644 --- a/pixelgl/window.go +++ b/pixelgl/window.go @@ -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) + }) +} From 7a67b10ceca8f771f8644fd41e48b774c71c23e8 Mon Sep 17 00:00:00 2001 From: Theoo3 Date: Sat, 12 Sep 2020 11:02:02 -0700 Subject: [PATCH 2/2] undo go.mod change --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 10281bf..dc9ce1c 100644 --- a/go.mod +++ b/go.mod @@ -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 + github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 // indirect 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