WidgetBase implements the [Widget] interface and provides the core functionality of a widget. You must use WidgetBase as an embedded struct in all higher-level widget types. It renders the standard box model, but does not layout or render any children; see [Frame] for that.
| 143 | // widget types. It renders the standard box model, but does not layout or render |
| 144 | // any children; see [Frame] for that. |
| 145 | type WidgetBase struct { |
| 146 | tree.NodeBase |
| 147 | |
| 148 | // Tooltip is the text for the tooltip for this widget, |
| 149 | // which can use HTML formatting. |
| 150 | Tooltip string `json:",omitempty"` |
| 151 | |
| 152 | // Parts are a separate tree of sub-widgets that can be used to store |
| 153 | // orthogonal parts of a widget when necessary to separate them from children. |
| 154 | // For example, [Tree]s use parts to separate their internal parts from |
| 155 | // the other child tree nodes. Composite widgets like buttons should |
| 156 | // NOT use parts to store their components; parts should only be used when |
| 157 | // absolutely necessary. Use [WidgetBase.newParts] to make the parts. |
| 158 | Parts *Frame `copier:"-" json:"-" xml:"-" set:"-"` |
| 159 | |
| 160 | // Geom has the full layout geometry for size and position of this widget. |
| 161 | Geom geomState `edit:"-" copier:"-" json:"-" xml:"-" set:"-"` |
| 162 | |
| 163 | // OverrideStyle, if true, indicates override the computed styles of the widget |
| 164 | // and allow directly editing [WidgetBase.Styles]. It is typically only set in |
| 165 | // the inspector. |
| 166 | OverrideStyle bool `copier:"-" json:"-" xml:"-" set:"-"` |
| 167 | |
| 168 | // Styles are styling settings for this widget. They are set by |
| 169 | // [WidgetBase.Stylers] in [WidgetBase.Style]. |
| 170 | Styles styles.Style `json:"-" xml:"-" set:"-"` |
| 171 | |
| 172 | // Stylers is a tiered set of functions that are called in sequential |
| 173 | // ascending order (so the last added styler is called last and |
| 174 | // thus can override all other stylers) to style the element. |
| 175 | // These should be set using the [WidgetBase.Styler], [WidgetBase.FirstStyler], |
| 176 | // and [WidgetBase.FinalStyler] functions. |
| 177 | Stylers tiered.Tiered[[]func(s *styles.Style)] `copier:"-" json:"-" xml:"-" set:"-" edit:"-" display:"add-fields"` |
| 178 | |
| 179 | // Listeners is a tiered set of event listener functions for processing events on this widget. |
| 180 | // They are called in sequential descending order (so the last added listener |
| 181 | // is called first). They should be added using the [WidgetBase.On], [WidgetBase.OnFirst], |
| 182 | // and [WidgetBase.OnFinal] functions, or any of the various On{EventType} helper functions. |
| 183 | Listeners tiered.Tiered[events.Listeners] `copier:"-" json:"-" xml:"-" set:"-" edit:"-" display:"add-fields"` |
| 184 | |
| 185 | // ContextMenus is a slice of menu functions to call to construct |
| 186 | // the widget's context menu on an [events.ContextMenu]. The |
| 187 | // functions are called in reverse order such that the elements |
| 188 | // added in the last function are the first in the menu. |
| 189 | // Context menus should be added through [WidgetBase.AddContextMenu]. |
| 190 | // Separators will be added between each context menu function. |
| 191 | ContextMenus []func(m *Scene) `copier:"-" json:"-" xml:"-" set:"-" edit:"-"` |
| 192 | |
| 193 | // Scene is the overall Scene to which we belong. It is automatically |
| 194 | // by widgets whenever they are added to another widget parent. |
| 195 | Scene *Scene `copier:"-" json:"-" xml:"-" set:"-"` |
| 196 | |
| 197 | // ValueUpdate is a function set by [Bind] that is called in |
| 198 | // [WidgetBase.UpdateWidget] to update the widget's value from the bound value. |
| 199 | // It should not be accessed by end users. |
| 200 | ValueUpdate func() `copier:"-" json:"-" xml:"-" set:"-"` |
| 201 | |
| 202 | // ValueOnChange is a function set by [Bind] that is called when |
nothing calls this directly
no outgoing calls
no test coverage detected