wails/v3/pkg/application/messageprocessor_clipboard.go
Andrey Pshenkin 561473d992
[V3] Refactor binding transport layer (#4702)
* custom transport initial

* transport codecs

* runtime set transport

* events transport

* clauded example

* bundled runtime

* wip: transport

* rework transports

* rework dialog responses

* cleanup

* cleanup

* improve error handling in HTTPTransport

* cleanup

* cleanup

* cleanup

* cleanup

* review changes

* review changes

* review changes

* review changes

* review changes

* review changes

* review changes

* move documentation to website docs

* update doc

* update changelog

* introduce JSClient method for transport for embedding JS part in transport

---------

Co-authored-by: Atterpac <Capretta.Michael@gmail.com>
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2025-12-07 22:19:12 +11:00

37 lines
800 B
Go

package application
import (
"github.com/wailsapp/wails/v3/pkg/errs"
)
const (
ClipboardSetText = 0
ClipboardText = 1
)
var clipboardMethods = map[int]string{
ClipboardSetText: "SetText",
ClipboardText: "Text",
}
func (m *MessageProcessor) processClipboardMethod(req *RuntimeRequest) (any, error) {
args := req.Args.AsMap()
var text string
switch req.Method {
case ClipboardSetText:
textp := args.String("text")
if textp == nil {
return nil, errs.NewInvalidClipboardCallErrorf("missing argument 'text'")
}
text = *textp
globalApplication.Clipboard.SetText(text)
return unit, nil
case ClipboardText:
text, _ = globalApplication.Clipboard.Text()
return text, nil
default:
return nil, errs.NewInvalidClipboardCallErrorf("unknown method: %d", req.Method)
}
}