mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
io/input,io/clipboard: [API] replace ReadOp with command
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -5,33 +5,20 @@ package clipboard
|
||||
import (
|
||||
"io"
|
||||
|
||||
"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
|
||||
}
|
||||
|
||||
// WriteCmd copies Text to the clipboard.
|
||||
type WriteCmd struct {
|
||||
Type string
|
||||
Data io.ReadCloser
|
||||
}
|
||||
|
||||
// ReadOp requests the text of the clipboard, delivered to
|
||||
// the current handler through an Event.
|
||||
type ReadOp struct {
|
||||
// ReadCmd requests the text of the clipboard, delivered to
|
||||
// the handler through an [io/transfer.DataEvent].
|
||||
type ReadCmd struct {
|
||||
Tag event.Tag
|
||||
}
|
||||
|
||||
func (h ReadOp) Add(o *op.Ops) {
|
||||
data := ops.Write1(&o.Internal, ops.TypeClipboardReadLen, h.Tag)
|
||||
data[0] = byte(ops.TypeClipboardRead)
|
||||
}
|
||||
|
||||
func (Event) ImplementsEvent() {}
|
||||
|
||||
func (WriteCmd) ImplementsCommand() {}
|
||||
func (ReadCmd) ImplementsCommand() {}
|
||||
|
||||
Reference in New Issue
Block a user