mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
gesture: report one event at a time
Events are now delivered one at a time, and this change makes the corresponding change to gestures. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+15
-3
@@ -61,7 +61,11 @@ func (s *Scrollbar) Update(gtx layout.Context, axis layout.Axis, viewportStart,
|
||||
}
|
||||
|
||||
// Jump to a click in the track.
|
||||
for _, event := range s.track.Update(gtx.Source) {
|
||||
for {
|
||||
event, ok := s.track.Update(gtx.Source)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
if event.Kind != gesture.KindClick ||
|
||||
event.Modifiers != key.Modifiers(0) ||
|
||||
event.NumClicks > 1 {
|
||||
@@ -80,7 +84,11 @@ func (s *Scrollbar) Update(gtx layout.Context, axis layout.Axis, viewportStart,
|
||||
}
|
||||
|
||||
// Offset to account for any drags.
|
||||
for _, event := range s.drag.Update(gtx.Metric, gtx.Source, gesture.Axis(axis)) {
|
||||
for {
|
||||
event, ok := s.drag.Update(gtx.Metric, gtx.Source, gesture.Axis(axis))
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
switch event.Kind {
|
||||
case pointer.Drag:
|
||||
case pointer.Release, pointer.Cancel:
|
||||
@@ -136,7 +144,11 @@ func (s *Scrollbar) Update(gtx layout.Context, axis layout.Axis, viewportStart,
|
||||
|
||||
// Process events from the indicator so that hover is
|
||||
// detected properly.
|
||||
_ = s.indicator.Update(gtx.Source)
|
||||
for {
|
||||
if _, ok := s.indicator.Update(gtx.Source); !ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AddTrack configures the track click listener for the scrollbar to use
|
||||
|
||||
Reference in New Issue
Block a user