mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3 windows] Add clipboard support
This commit is contained in:
parent
ae691b8e52
commit
833671d30c
3 changed files with 21 additions and 20 deletions
|
|
@ -2,7 +2,7 @@ package application
|
|||
|
||||
type clipboardImpl interface {
|
||||
setText(text string) bool
|
||||
text() string
|
||||
text() (string, bool)
|
||||
}
|
||||
|
||||
type Clipboard struct {
|
||||
|
|
@ -19,6 +19,6 @@ func (c *Clipboard) SetText(text string) bool {
|
|||
return c.impl.setText(text)
|
||||
}
|
||||
|
||||
func (c *Clipboard) Text() string {
|
||||
func (c *Clipboard) Text() (string, bool) {
|
||||
return c.impl.text()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ func (m macosClipboard) setText(text string) bool {
|
|||
return bool(success)
|
||||
}
|
||||
|
||||
func (m macosClipboard) text() string {
|
||||
func (m macosClipboard) text() (string, bool) {
|
||||
clipboardLock.RLock()
|
||||
defer clipboardLock.RUnlock()
|
||||
clipboardText := C.getClipboardText()
|
||||
result := C.GoString(clipboardText)
|
||||
return result
|
||||
return result, true
|
||||
}
|
||||
|
||||
func newClipboardImpl() *macosClipboard {
|
||||
|
|
|
|||
|
|
@ -2,25 +2,26 @@
|
|||
|
||||
package application
|
||||
|
||||
type windowsClipboard struct{}
|
||||
import (
|
||||
"github.com/wailsapp/wails/v3/pkg/w32"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func (m windowsClipboard) setText(text string) bool {
|
||||
//clipboardLock.Lock()
|
||||
//defer clipboardLock.Unlock()
|
||||
//cText := C.CString(text)
|
||||
//success := C.setClipboardText(cText)
|
||||
//C.free(unsafe.Pointer(cText))
|
||||
//return bool(success)
|
||||
panic("implement me")
|
||||
type windowsClipboard struct {
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
func (m windowsClipboard) text() string {
|
||||
//clipboardLock.RLock()
|
||||
//defer clipboardLock.RUnlock()
|
||||
//clipboardText := C.getClipboardText()
|
||||
//result := C.GoString(clipboardText)
|
||||
//return result
|
||||
panic("implement me")
|
||||
func (m *windowsClipboard) setText(text string) bool {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
return w32.SetClipboardText(text) == nil
|
||||
}
|
||||
|
||||
func (m *windowsClipboard) text() (string, bool) {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
text, err := w32.GetClipboardText()
|
||||
return text, err == nil
|
||||
}
|
||||
|
||||
func newClipboardImpl() *windowsClipboard {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue