MCPcopy Create free account
hub / github.com/gioui/gio / Push

Method Push

io/input/pointer.go:730–784  ·  view source on GitHub ↗
(handlers map[event.Tag]*handler, state pointerState, e pointer.Event)

Source from the content-addressed store, hash-verified

728}
729
730func (q *pointerQueue) Push(handlers map[event.Tag]*handler, state pointerState, e pointer.Event) (pointerState, []taggedEvent) {
731 var evts []taggedEvent
732 if e.Kind == pointer.Cancel {
733 for k := range handlers {
734 evts = append(evts, taggedEvent{
735 event: pointer.Event{Kind: pointer.Cancel},
736 tag: k,
737 })
738 }
739 state.pointers = nil
740 return state, evts
741 }
742 if e.Kind == pointer.Scroll {
743 // Scroll events are not bound to a pointer; see pointer.Event.PointerID.
744 return state, q.deliverScrollEvent(handlers, evts, e)
745 }
746 state, pidx := state.pointerOf(e)
747 p := state.pointers[pidx]
748
749 switch e.Kind {
750 case pointer.Press:
751 p, evts, state.cursor, _ = q.deliverEnterLeaveEvents(handlers, state.cursor, p, evts, e)
752 p.pressed = true
753 evts = q.deliverEvent(handlers, p, evts, e)
754 case pointer.Move:
755 if p.pressed {
756 e.Kind = pointer.Drag
757 }
758 p, evts, state.cursor, _ = q.deliverEnterLeaveEvents(handlers, state.cursor, p, evts, e)
759 evts = q.deliverEvent(handlers, p, evts, e)
760 if p.pressed {
761 p, evts = q.deliverDragEvent(handlers, p, evts)
762 }
763 case pointer.Leave:
764 p, evts, state.cursor, _ = q.deliverEnterLeaveEvents(handlers, state.cursor, p, evts, e)
765 case pointer.Release:
766 evts = q.deliverEvent(handlers, p, evts, e)
767 p.pressed = false
768 p, evts, state.cursor, _ = q.deliverEnterLeaveEvents(handlers, state.cursor, p, evts, e)
769 p, evts = q.deliverDropEvent(handlers, p, evts)
770 default:
771 panic("unsupported pointer event type")
772 }
773
774 p.last = e
775
776 if !p.pressed && len(p.entered) == 0 {
777 // No longer need to track pointer.
778 state.pointers = slices.Concat(state.pointers[:pidx:pidx], state.pointers[pidx+1:])
779 } else {
780 state.pointers = slices.Clone(state.pointers)
781 state.pointers[pidx] = p
782 }
783 return state, evts
784}
785
786// deliverScrollEvent delivers scroll events to the handlers hit by the event coordinate.
787func (q *pointerQueue) deliverScrollEvent(handlers map[event.Tag]*handler, evts []taggedEvent, e pointer.Event) []taggedEvent {

Callers 15

processEventMethod · 0.45
TestPointerMoveFunction · 0.45
TestPointerLeaveFunction · 0.45
TestPointerTypesFunction · 0.45
TestPointerSystemActionFunction · 0.45
TestPointerPriorityFunction · 0.45
TestMultipleAreasFunction · 0.45
TestCursorFunction · 0.45
TestPassOpFunction · 0.45
TestAreaPassthroughFunction · 0.45
TestEllipseFunction · 0.45

Calls 6

deliverScrollEventMethod · 0.95
deliverEventMethod · 0.95
deliverDragEventMethod · 0.95
deliverDropEventMethod · 0.95
pointerOfMethod · 0.80

Tested by 15

TestPointerMoveFunction · 0.36
TestPointerLeaveFunction · 0.36
TestPointerTypesFunction · 0.36
TestPointerSystemActionFunction · 0.36
TestPointerPriorityFunction · 0.36
TestMultipleAreasFunction · 0.36
TestCursorFunction · 0.36
TestPassOpFunction · 0.36
TestAreaPassthroughFunction · 0.36
TestEllipseFunction · 0.36
TestTransferFunction · 0.36