gesture: [API] rename ClickType to ClickKind

"Kind" is the Go idiomatic name for distinguishing structs outside of
the type system.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-10-06 18:33:56 -05:00
parent 650ccea28d
commit 1686874d07
7 changed files with 31 additions and 31 deletions
+4 -4
View File
@@ -149,8 +149,8 @@ func (b *Clickable) update(gtx layout.Context) {
b.prevClicks = n
for _, e := range b.click.Events(gtx) {
switch e.Type {
case gesture.TypeClick:
switch e.Kind {
case gesture.KindClick:
b.clicks = append(b.clicks, Click{
Modifiers: e.Modifiers,
NumClicks: e.NumClicks,
@@ -158,14 +158,14 @@ func (b *Clickable) update(gtx layout.Context) {
if l := len(b.history); l > 0 {
b.history[l-1].End = gtx.Now
}
case gesture.TypeCancel:
case gesture.KindCancel:
for i := range b.history {
b.history[i].Cancelled = true
if b.history[i].End.IsZero() {
b.history[i].End = gtx.Now
}
}
case gesture.TypePress:
case gesture.KindPress:
if e.Source == pointer.Mouse {
key.FocusOp{Tag: &b.keyTag}.Add(gtx.Ops)
}
+2 -2
View File
@@ -238,8 +238,8 @@ func (e *Editor) processPointer(gtx layout.Context) {
switch evt := evt.(type) {
case gesture.ClickEvent:
switch {
case evt.Type == gesture.TypePress && evt.Source == pointer.Mouse,
evt.Type == gesture.TypeClick && evt.Source != pointer.Mouse:
case evt.Kind == gesture.KindPress && evt.Source == pointer.Mouse,
evt.Kind == gesture.KindClick && evt.Source != pointer.Mouse:
prevCaretPos, _ := e.text.Selection()
e.blinkStart = gtx.Now
e.text.MoveCoord(image.Point{
+3 -3
View File
@@ -74,12 +74,12 @@ func (e *Enum) Layout(gtx layout.Context, k string, content layout.Widget) layou
}
clk := &state.click
for _, ev := range clk.Events(gtx) {
switch ev.Type {
case gesture.TypePress:
switch ev.Kind {
case gesture.KindPress:
if ev.Source == pointer.Mouse {
key.FocusOp{Tag: &state.tag}.Add(gtx.Ops)
}
case gesture.TypeClick:
case gesture.KindClick:
if state.key != e.Value {
e.Value = state.key
e.changed = true
+1 -1
View File
@@ -62,7 +62,7 @@ func (s *Scrollbar) Layout(gtx layout.Context, axis layout.Axis, viewportStart,
// Jump to a click in the track.
for _, event := range s.track.Events(gtx) {
if event.Type != gesture.TypeClick ||
if event.Kind != gesture.KindClick ||
event.Modifiers != key.Modifiers(0) ||
event.NumClicks > 1 {
continue
+2 -2
View File
@@ -236,8 +236,8 @@ func (e *Selectable) processPointer(gtx layout.Context) {
switch evt := evt.(type) {
case gesture.ClickEvent:
switch {
case evt.Type == gesture.TypePress && evt.Source == pointer.Mouse,
evt.Type == gesture.TypeClick && evt.Source != pointer.Mouse:
case evt.Kind == gesture.KindPress && evt.Source == pointer.Mouse,
evt.Kind == gesture.KindClick && evt.Source != pointer.Mouse:
prevCaretPos, _ := e.text.Selection()
e.text.MoveCoord(image.Point{
X: int(math.Round(float64(evt.Position.X))),