2
0
mirror of https://github.com/rivo/tview.git synced 2024-11-15 06:12:46 +00:00

Added SetFocus() to Modal, focuses on the provided button. Resolves #364

This commit is contained in:
Oliver 2019-11-27 18:27:26 +01:00
parent 2d957c4be0
commit 0f6549646b
2 changed files with 9 additions and 2 deletions

View File

@ -126,6 +126,12 @@ func (m *Modal) ClearButtons() *Modal {
return m
}
// SetFocus shifts the focus to the button with the given index.
func (m *Modal) SetFocus(index int) *Modal {
m.form.SetFocus(index)
return m
}
// Focus is called when this primitive receives focus.
func (m *Modal) Focus(delegate func(p Primitive)) {
delegate(m.form)

View File

@ -298,8 +298,9 @@ func (t *TextView) SetRegions(regions bool) *TextView {
// SetChangedFunc sets a handler function which is called when the text of the
// text view has changed. This is useful when text is written to this io.Writer
// in a separate goroutine. This does not automatically cause the screen to be
// refreshed so you may want to use the "changed" handler to redraw the screen.
// in a separate goroutine. Doing so does not automatically cause the screen to
// be refreshed so you may want to use the "changed" handler to redraw the
// screen.
//
// Note that to avoid race conditions or deadlocks, there are a few rules you
// should follow: