io/input,io/clipboard: [API] replace WriteOp with command

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-10-09 18:27:01 -05:00
parent a3c539b3c2
commit d51aea553f
16 changed files with 67 additions and 62 deletions
+1 -1
View File
@@ -417,7 +417,7 @@ func (e *Editor) command(gtx layout.Context, k key.Event) {
case "C", "X":
e.scratch = e.text.SelectedText(e.scratch)
if text := string(e.scratch); text != "" {
clipboard.WriteOp{Text: text}.Add(gtx.Ops)
gtx.Queue(clipboard.WriteCmd{Type: "application/text", Data: io.NopCloser(strings.NewReader(text))})
if k.Name == "X" && !e.ReadOnly {
e.Delete(1)
}
+2 -1
View File
@@ -2,6 +2,7 @@ package widget
import (
"image"
"io"
"math"
"strings"
@@ -332,7 +333,7 @@ func (e *Selectable) command(gtx layout.Context, k key.Event) {
case "C", "X":
e.scratch = e.text.SelectedText(e.scratch)
if text := string(e.scratch); text != "" {
clipboard.WriteOp{Text: text}.Add(gtx.Ops)
gtx.Queue(clipboard.WriteCmd{Type: "application/text", Data: io.NopCloser(strings.NewReader(text))})
}
// Select all
case "A":