mirror of https://github.com/mum4k/termdash.git
Updated Container API (markdown)
parent
24c59b8a5e
commit
796e8a8160
|
@ -141,6 +141,36 @@ if err != nil {
|
|||
The following options can be used to align a widget within the container both
|
||||
horizontally and vertically.
|
||||
|
||||
[[/images/container-api/aligned_button.gif|aligned_button]]
|
||||
|
||||
The following code aligns the button widget into the top right corner as shown above:
|
||||
|
||||
```go
|
||||
tb, err := termbox.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer tb.Close()
|
||||
|
||||
b, err := button.New("hello world", func() error {
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.PlaceWidget(b),
|
||||
container.AlignHorizontal(align.HorizontalRight),
|
||||
container.AlignVertical(align.VerticalTop),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
```
|
||||
|
||||
#### [container.AlignHorizontal](https://godoc.org/github.com/mum4k/termdash/container#AlignHorizontal)
|
||||
|
||||
The **container.AlignHorizontal** option is used to specify horizontal alignment for the widget. Refer to the [[Align API|align-api]] for alignment options.
|
||||
|
|
Loading…
Reference in New Issue