eventx

package
Version: v0.0.0-...-1978dde Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2022 License: MIT, Unlicense Imports: 2 Imported by: 6

README

eventx

Go Reference

This package provides types to manage Gio events.

State

This package has no stable API, and should always be locked to a particular commit with go modules.

Features

Spy

A spy is an event processing tool that wraps a Gio event queue. Whenever its Events method is invoked, it makes the same Events call on the wrapped queue, but makes a copy of all events that it receives from the underlying queue. This copy can be accessed using the AllEvents() method.

The primary use-case for this type is observing the raw event stream for a UI component that consumes some-but-not-all of the relevant events. For instance, you can extend the keyboard shortcuts understood by material.Editor by providing a spied-upon layout.Context to it and then (after laying it out) checking the events within the spy for the keystrokes of interest.

The Spy was conceived by ~eliasnaur in this mailing list discussion.

EventGroup

This type is returned by the Spy, but can also be instantiated literally. It functions as a simple standalone event queue tha responds to a single, specific tag.

CombinedQueue

CombinedQueue combines the output of two queues. This can be useful to join the events of the "real" gio event queue with a fake one like an EventGroup.

Documentation

Overview

Package eventx provides types to help manage Gio events and event routing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combine

func Combine(gtx layout.Context, queue event.Queue) layout.Context

Combine configures the provided context so that its event queue is a CombinedQueue of its original event queue and the provided event queue.

Types

type CombinedQueue

type CombinedQueue struct {
	A, B event.Queue
}

CombinedQueue combines the results of two queues into one.

func (CombinedQueue) Events

func (u CombinedQueue) Events(tag event.Tag) []event.Event

Events returns the combined results of the two queues.

type EventGroup

type EventGroup struct {
	event.Tag
	Items []event.Event
}

EventGroup contains a list of events and the tag that they are associated with. It can be used as an event.Queue.

func (*EventGroup) Events

func (e *EventGroup) Events(tag event.Tag) (out []event.Event)

type Spy

type Spy struct {
	Queue event.Queue
	// contains filtered or unexported fields
}

Spy wraps an event.Queue and makes a copy of each event that is requested from the queue. These copies can be accessed by higher-level logic after laying out widgets that consume events.

func Enspy

func Enspy(gtx layout.Context) (*Spy, layout.Context)

Enspy returns a new spy and a copy of the layout.Context configured to use that spy wrapped around its original queue.

func (*Spy) AllEvents

func (s *Spy) AllEvents() (events []EventGroup)

AllEvents returns all events that have been requested via the Events() method since the last call to AllEvents().

func (*Spy) Events

func (s *Spy) Events(tag event.Tag) []event.Event

Events returns the events for a given tag from the wrapped Queue.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL