Browse Source

Add documentation for GetChildren methods

merge-requests/1/merge
Trevor Slocum 2 years ago
parent
commit
51704b9844
  1. 1
      CHANGELOG
  2. 2
      application.go
  3. 2
      box.go
  4. 4
      checkbox.go
  5. 8
      doc.go
  6. 3
      events.go
  7. 1
      flex.go
  8. 1
      form.go
  9. 1
      frame.go
  10. 1
      grid.go
  11. 1
      modal.go
  12. 1
      pages.go
  13. 2
      primitive.go

1
CHANGELOG

@ -2,6 +2,7 @@ v1.4.1 (WIP) @@ -2,6 +2,7 @@ v1.4.1 (WIP)
- Add ProgressBar widget
- Add Application.RingBell
- Add example multi-layout application and mouse-enabled application
- Add documentation for GetChildren methods
v1.4.0 (2020-01-16)
- Bump version to resolve issues with "go get"

2
application.go

@ -11,7 +11,7 @@ import ( @@ -11,7 +11,7 @@ import (
// The size of the event/update/redraw channels.
const queueSize = 100
// The minimum duration between resize event callbacks.
// ResizeEventThrottle is the minimum duration between resize event callbacks.
const ResizeEventThrottle = 200 * time.Millisecond
// Application represents the top node of an application.

2
box.go

@ -403,7 +403,7 @@ func (b *Box) GetFocusable() Focusable { @@ -403,7 +403,7 @@ func (b *Box) GetFocusable() Focusable {
return b.focus
}
// GetChildren gets the children.
// GetChildren returns nil because Box doesn't have any use for children.
func (b *Box) GetChildren() []Primitive {
return nil
}

4
checkbox.go

@ -129,9 +129,9 @@ func (c *Checkbox) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldT @@ -129,9 +129,9 @@ func (c *Checkbox) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldT
func (c *Checkbox) GetFieldWidth() int {
if c.message == "" {
return 1
} else {
return 2 + len(c.message)
}
return 2 + len(c.message)
}
// SetChangedFunc sets a handler which is called when the checked state of this

8
doc.go

@ -19,6 +19,7 @@ The package implements the following widgets: @@ -19,6 +19,7 @@ The package implements the following widgets:
- DropDown: Drop-down selection fields.
- Checkbox: Selectable checkbox for boolean values.
- Button: Buttons which get activated when the user selects them.
- ProgressBar: Indicates the progress of an operation.
- Form: Forms composed of input fields, drop down selections, checkboxes, and
buttons.
- Modal: A centered window with a text message and one or more buttons.
@ -192,9 +193,8 @@ therefore available for all widgets, too. @@ -192,9 +193,8 @@ therefore available for all widgets, too.
All widgets also implement the Primitive interface. There is also the Focusable
interface which is used to override functions in subclassing types.
The cview package is based on https://github.com/gdamore/tcell. It uses types
and constants from that package (e.g. colors and keyboard values).
This package does not process mouse input (yet).
This package is a fork of [tview](https://github.com/rivo/tview), which is
based on https://github.com/gdamore/tcell. It uses types and constants from
that package (e.g. colors and keyboard values).
*/
package cview

3
events.go

@ -10,6 +10,7 @@ type EventKey = tcell.EventKey @@ -10,6 +10,7 @@ type EventKey = tcell.EventKey
// MouseAction are bit flags indicating what the mouse is logically doing.
type MouseAction int
// All MouseActions
const (
MouseDown MouseAction = 1 << iota
MouseUp
@ -35,7 +36,7 @@ func (e *EventMouse) Application() *Application { @@ -35,7 +36,7 @@ func (e *EventMouse) Application() *Application {
return e.app
}
// MouseAction gets the mouse action of this event.
// Action gets the mouse action of this event.
func (e *EventMouse) Action() MouseAction {
return e.action
}

1
flex.go

@ -196,6 +196,7 @@ func (f *Flex) HasFocus() bool { @@ -196,6 +196,7 @@ func (f *Flex) HasFocus() bool {
return false
}
// GetChildren returns all primitives that have been added.
func (f *Flex) GetChildren() []Primitive {
children := make([]Primitive, len(f.items))
for i, item := range f.items {

1
form.go

@ -621,6 +621,7 @@ func (f *Form) focusIndex() int { @@ -621,6 +621,7 @@ func (f *Form) focusIndex() int {
return -1
}
// GetChildren returns all primitives that have been added.
func (f *Form) GetChildren() []Primitive {
children := make([]Primitive, len(f.items)+len(f.buttons))
i := 0

1
frame.go

@ -156,6 +156,7 @@ func (f *Frame) HasFocus() bool { @@ -156,6 +156,7 @@ func (f *Frame) HasFocus() bool {
return false
}
// GetChildren returns all primitives that have been added.
func (f *Frame) GetChildren() []Primitive {
return []Primitive{f.primitive}
}

1
grid.go

@ -661,6 +661,7 @@ func (g *Grid) Draw(screen tcell.Screen) { @@ -661,6 +661,7 @@ func (g *Grid) Draw(screen tcell.Screen) {
}
}
// GetChildren returns all primitives that have been added.
func (g *Grid) GetChildren() []Primitive {
children := make([]Primitive, len(g.items))
for i, item := range g.items {

1
modal.go

@ -176,6 +176,7 @@ func (m *Modal) Draw(screen tcell.Screen) { @@ -176,6 +176,7 @@ func (m *Modal) Draw(screen tcell.Screen) {
m.frame.Draw(screen)
}
// GetChildren returns all primitives that have been added.
func (m *Modal) GetChildren() []Primitive {
return []Primitive{m.frame}
}

1
pages.go

@ -279,6 +279,7 @@ func (p *Pages) Draw(screen tcell.Screen) { @@ -279,6 +279,7 @@ func (p *Pages) Draw(screen tcell.Screen) {
}
}
// GetChildren returns all primitives that have been added.
func (p *Pages) GetChildren() []Primitive {
var children []Primitive
for _, page := range p.pages {

2
primitive.go

@ -44,7 +44,7 @@ type Primitive interface { @@ -44,7 +44,7 @@ type Primitive interface {
// GetFocusable returns the item's Focusable.
GetFocusable() Focusable
// GetChildren gets the children.
// GetChildren returns all child primitives that have been added.
GetChildren() []Primitive
// MouseHandler returns a handler which receives mouse events.

Loading…
Cancel
Save