blob: ae4a4359494e9b14c8d296e8220bc5194c2dda99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// SPDX-License-Identifier: Unlicense OR MIT
package clipboard
import (
"gioui.org/internal/ops"
"gioui.org/io/event"
"gioui.org/op"
)
// Event is generated when the clipboard content is requested.
type Event struct {
Text string
}
// ReadOp requests the text of the clipboard, delivered to
// the current handler through an Event.
type ReadOp struct {
Tag event.Tag
}
// WriteOp copies Text to the clipboard.
type WriteOp struct {
Text string
}
func (h ReadOp) Add(o *op.Ops) {
data := ops.Write1(&o.Internal, ops.TypeClipboardReadLen, h.Tag)
data[0] = byte(ops.TypeClipboardRead)
}
func (h WriteOp) Add(o *op.Ops) {
data := ops.Write1(&o.Internal, ops.TypeClipboardWriteLen, &h.Text)
data[0] = byte(ops.TypeClipboardWrite)
}
func (Event) ImplementsEvent() {}
|