From b68c9c23c81c124b8517e5ae070e15cab52d6c50 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 11 Aug 2019 12:31:39 +0200 Subject: [PATCH] ui/input: expand package documentation Signed-off-by: Elias Naur --- ui/input/input.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ui/input/input.go b/ui/input/input.go index b4db4302..b6f9deb0 100644 --- a/ui/input/input.go +++ b/ui/input/input.go @@ -1,7 +1,33 @@ // SPDX-License-Identifier: Unlicense OR MIT -// Package input exposes a unified interface to input sources. Subpackages -// such as pointer and key provide the interfaces for specific input types. +/* +Package input exposes a unified interface for receiving input +events. + +For example: + + var queue input.Queue = ... + + for e, ok := queue.Next(h); ok; e, ok = queue.Next(h) { + switch e.(type) { + ... + } + } + +In general, handlers must be declared before events become +available. Other packages such as pointer and key provide +the means for declaring handlers for specific input types. + +The following example marks a handler ready for key input: + + import gioui.org/ui/input + import gioui.org/ui/key + + var ops ui.Ops + var h *Handler = ... + key.HandlerOp{Key: h}.Add(ops) + +*/ package input // Queue maps an event handler key to the events