From a463c073ed96ea68343cb6630a3461d4a5222de9 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 16 Aug 2019 20:31:50 -0400 Subject: [PATCH] Documentation fix. --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 34628a5..4c77565 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,12 @@ type Enclosure interface { func Enclose(e Enclosure, w ...Widget) Widget { ... } ``` -The `Context` struct also contains a `map[string]interface{}` allowing arbitrary -data to be maintained. This can be used, for example, to define themes, and control -the operation of a `WidgetCombinator` during operation. For example> +The giowrap package also includes a private package-global variable called +extra that is a []interface{}, allowing arbitrary data to be maintained by +UI elements. Elements can request access to the structure when they are +allocated and they are returned a unique integer index into the slice. This +can be used, for example, to define themes, and control +the operation of a `WidgetCombinator` during operation. For example: ```go type fWidget struct { l Layout } @@ -42,7 +45,7 @@ func NewfWidget(l layout) fWidget { return fWidget{ l: l } } func Flexible(v float32) Widget { return NewfWidget(func(ctx Context) Context { - ctx.extra["Flexible"] = v + extra.data[extra.cur].(*FlexOpts).flexible = v return ctx }) }