mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 23:55:39 +00:00
391725b9d0
Merge package opconsts into ops as well; it only existed to break import cycles. Signed-off-by: Elias Naur <mail@eliasnaur.com>
38 lines
767 B
Go
38 lines
767 B
Go
// 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 := o.Internal.Write1(ops.TypeClipboardReadLen, h.Tag)
|
|
data[0] = byte(ops.TypeClipboardRead)
|
|
}
|
|
|
|
func (h WriteOp) Add(o *op.Ops) {
|
|
data := o.Internal.Write1(ops.TypeClipboardWriteLen, &h.Text)
|
|
data[0] = byte(ops.TypeClipboardWrite)
|
|
}
|
|
|
|
func (Event) ImplementsEvent() {}
|