[PATCH gio] widget: show pointer for clickable things
Export this patch
From: Egon Elbre <egonelbre@gmail.com>
Changing cursor to "Pointer" is an important signifier for showing that
something is clickable.
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
---
widget/button.go | 1 +
widget/enum.go | 1 +
widget/float.go | 1 +
3 files changed, 3 insertions(+)
diff --git a/widget/button.go b/widget/button.go
index f534920..68d6a6a 100644
--- a/widget/button.go
+++ b/widget/button.go
@@ -76,6 +76,7 @@ func (b *Clickable) Layout(gtx layout.Context) layout.Dimensions {
b.update(gtx)
stack := op.Push(gtx.Ops)
pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Add(gtx.Ops)
+ pointer.CursorNameOp{Name: pointer.CursorPointer}.Add(gtx.Ops)
b.click.Add(gtx.Ops)
stack.Pop()
for len(b.history) > 0 {
diff --git a/widget/enum.go b/widget/enum.go
index 442000e..d8f7682 100644
--- a/widget/enum.go
+++ b/widget/enum.go
@@ -39,6 +39,7 @@ func (e *Enum) Changed() bool {
func (e *Enum) Layout(gtx layout.Context, key string) layout.Dimensions {
defer op.Push(gtx.Ops).Pop()
pointer.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Add(gtx.Ops)
+ pointer.CursorNameOp{Name: pointer.CursorPointer}.Add(gtx.Ops)
if index(e.values, key) == -1 {
e.values = append(e.values, key)
diff --git a/widget/float.go b/widget/float.go
index 8d21c68..6b64d25 100644
--- a/widget/float.go
+++ b/widget/float.go
@@ -57,6 +57,7 @@ func (f *Float) Layout(gtx layout.Context, pointerMargin int, min, max float32)
rect.Min.X -= pointerMargin
rect.Max.X += pointerMargin
pointer.Rect(rect).Add(gtx.Ops)
+ pointer.CursorNameOp{Name: pointer.CursorPointer}.Add(gtx.Ops)
f.drag.Add(gtx.Ops)
return layout.Dimensions{Size: size}
--
2.26.2
CursorPointer is widely used for Web UI, but rarely for native UI. I'm
not sure we want to unconditionally set CursorPointer for all
Clickables. Maybe a CursorClickable that is per-GOOS?
Elias