forked from joejulian/gio
io/input,io/transfer: [API] replace OfferOp with command
Also delete two tests that are no longer relevant. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+2
-6
@@ -77,12 +77,8 @@ func (d *Draggable) Update(gtx layout.Context) (mime string, requested bool) {
|
||||
|
||||
// Offer the data ready for a drop. Must be called after being Requested.
|
||||
// The mime must be one in the requested list.
|
||||
func (d *Draggable) Offer(ops *op.Ops, mime string, data io.ReadCloser) {
|
||||
transfer.OfferOp{
|
||||
Tag: &d.handle,
|
||||
Type: mime,
|
||||
Data: data,
|
||||
}.Add(ops)
|
||||
func (d *Draggable) Offer(gtx layout.Context, mime string, data io.ReadCloser) {
|
||||
gtx.Queue(transfer.OfferCmd{Tag: &d.handle, Type: mime, Data: data})
|
||||
}
|
||||
|
||||
// Pos returns the drag position relative to its initial click position.
|
||||
|
||||
+3
-3
@@ -51,12 +51,12 @@ func TestDraggable(t *testing.T) {
|
||||
},
|
||||
)
|
||||
ofr := &offer{data: "hello"}
|
||||
drag.Offer(gtx.Ops, "file", ofr)
|
||||
drag.Offer(gtx, "file", ofr)
|
||||
r.Frame(gtx.Ops)
|
||||
|
||||
evs := r.Events(drag)
|
||||
if len(evs) != 1 {
|
||||
t.Fatalf("expected 1 event, got %d", len(evs))
|
||||
if len(evs) != 2 {
|
||||
t.Fatalf("expected 2 event, got %d", len(evs))
|
||||
}
|
||||
ev := evs[0].(transfer.DataEvent)
|
||||
ev.Open = nil
|
||||
|
||||
@@ -94,7 +94,7 @@ func ExampleDraggable_Layout() {
|
||||
// drag must respond with an Offer event when requested.
|
||||
// Use the drag method for this.
|
||||
if m, ok := drag.Update(gtx); ok {
|
||||
drag.Offer(gtx.Ops, m, offer{Data: "hello world"})
|
||||
drag.Offer(gtx, m, offer{Data: "hello world"})
|
||||
}
|
||||
|
||||
// Setup the area for drops.
|
||||
|
||||
Reference in New Issue
Block a user