forked from joejulian/gio
ui/gesture: replace Click.Events with Click.Next
Everything else was converted to use the Next style event API, but Click was forgotten. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -124,9 +124,8 @@ func (c *Click) State() ClickState {
|
||||
return c.state
|
||||
}
|
||||
|
||||
// Events reports all click events for the available events.
|
||||
func (c *Click) Events(q input.Queue) []ClickEvent {
|
||||
var events []ClickEvent
|
||||
// Next returns the next click event, if any.
|
||||
func (c *Click) Next(q input.Queue) (ClickEvent, bool) {
|
||||
for evt, ok := q.Next(c); ok; evt, ok = q.Next(c) {
|
||||
e, ok := evt.(pointer.Event)
|
||||
if !ok {
|
||||
@@ -137,7 +136,7 @@ func (c *Click) Events(q input.Queue) []ClickEvent {
|
||||
wasPressed := c.state == StatePressed
|
||||
c.state = StateNormal
|
||||
if wasPressed {
|
||||
events = append(events, ClickEvent{Type: TypeClick, Position: e.Position, Source: e.Source})
|
||||
return ClickEvent{Type: TypeClick, Position: e.Position, Source: e.Source}, true
|
||||
}
|
||||
case pointer.Cancel:
|
||||
c.state = StateNormal
|
||||
@@ -146,7 +145,7 @@ func (c *Click) Events(q input.Queue) []ClickEvent {
|
||||
break
|
||||
}
|
||||
c.state = StatePressed
|
||||
events = append(events, ClickEvent{Type: TypePress, Position: e.Position, Source: e.Source})
|
||||
return ClickEvent{Type: TypePress, Position: e.Position, Source: e.Source}, true
|
||||
case pointer.Move:
|
||||
if c.state == StatePressed && !e.Hit {
|
||||
c.state = StateNormal
|
||||
@@ -155,7 +154,7 @@ func (c *Click) Events(q input.Queue) []ClickEvent {
|
||||
}
|
||||
}
|
||||
}
|
||||
return events
|
||||
return ClickEvent{}, false
|
||||
}
|
||||
|
||||
// Add the handler to the operation list to receive scroll events.
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ func (e *Editor) Next(cfg ui.Config, queue input.Queue) (EditorEvent, bool) {
|
||||
e.scrollOff.Y += sdist
|
||||
soff = e.scrollOff.Y
|
||||
}
|
||||
for _, evt := range e.clicker.Events(queue) {
|
||||
for evt, ok := e.clicker.Next(queue); ok; evt, ok = e.clicker.Next(queue) {
|
||||
switch {
|
||||
case evt.Type == gesture.TypePress && evt.Source == pointer.Mouse,
|
||||
evt.Type == gesture.TypeClick && evt.Source == pointer.Touch:
|
||||
|
||||
Reference in New Issue
Block a user