Browse Source

Add Box.ShowFocus

tablepad
Trevor Slocum 2 years ago
parent
commit
5c2dfbf231
  1. 1
      CHANGELOG
  2. 10
      box.go
  3. 2
      contextmenu.go
  4. 2
      go.mod
  5. 4
      go.sum

1
CHANGELOG

@ -1,4 +1,5 @@
v1.4.6 (WIP)
- Add Box.ShowFocus
- Add List.GetOffset, List.SetOffset and List.SetSelectedTextAttributes
- Add Vim-style keybindings to List
- Fix List not updating selected item before calling selected handlers

10
box.go

@ -471,6 +471,16 @@ func (b *Box) Draw(screen tcell.Screen) {
b.l.Unlock()
}
// ShowFocus sets the flag indicating whether or not the borders of this
// primitive should change thickness when focused.
func (b *Box) ShowFocus(showFocus bool) *Box {
b.l.Lock()
defer b.l.Unlock()
b.showFocus = showFocus
return b
}
// Focus is called when this primitive receives focus.
func (b *Box) Focus(delegate func(p Primitive)) {
b.l.Lock()

2
contextmenu.go

@ -33,13 +33,13 @@ func (c *ContextMenu) initializeList() {
SetHover(true).
SetWrapAround(true)
c.list.
ShowFocus(false).
SetBorder(true).
SetBorderPadding(
Styles.ContextMenuPaddingTop,
Styles.ContextMenuPaddingBottom,
Styles.ContextMenuPaddingLeft,
Styles.ContextMenuPaddingRight)
c.list.showFocus = false
}
// ContextMenuList returns the underlying List of the context menu.

2
go.mod

@ -7,6 +7,6 @@ require (
github.com/lucasb-eyer/go-colorful v1.0.3
github.com/mattn/go-runewidth v0.0.9
github.com/rivo/uniseg v0.1.0
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f // indirect
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f // indirect
golang.org/x/text v0.3.2 // indirect
)

4
go.sum

@ -16,8 +16,8 @@ github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f h1:mOhmO9WsBaJCNmaZHPtHs9wOcdqdKCjF6OPJlmDM3KI=
golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=

Loading…
Cancel
Save