event.go 766 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: Unlicense OR MIT
  2. // Package event contains types for event handling.
  3. package event
  4. import (
  5. "gioui.org/internal/ops"
  6. "gioui.org/op"
  7. )
  8. // Tag is the stable identifier for an event handler.
  9. // For a handler h, the tag is typically &h.
  10. type Tag interface{}
  11. // Event is the marker interface for events.
  12. type Event interface {
  13. ImplementsEvent()
  14. }
  15. // Filter represents a filter for [Event] types.
  16. type Filter interface {
  17. ImplementsFilter()
  18. }
  19. // Op declares a tag for input routing at the current transformation
  20. // and clip area hierarchy. It panics if tag is nil.
  21. func Op(o *op.Ops, tag Tag) {
  22. if tag == nil {
  23. panic("Tag must be non-nil")
  24. }
  25. data := ops.Write1(&o.Internal, ops.TypeInputLen, tag)
  26. data[0] = byte(ops.TypeInput)
  27. }