inputfields.go 557 B

1234567891011121314151617181920
  1. package ui
  2. import (
  3. "github.com/gdamore/tcell/v2"
  4. "github.com/rivo/tview"
  5. )
  6. // NewMessageInputField creates and returns a new message inputfield.
  7. func NewMessageInputField(onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey) *tview.InputField {
  8. i := tview.NewInputField()
  9. i.
  10. SetPlaceholder("Message...").
  11. SetPlaceholderTextColor(tcell.ColorWhite).
  12. SetFieldBackgroundColor(tview.Styles.PrimitiveBackgroundColor).
  13. SetInputCapture(onMessageInputFieldInputCapture).
  14. SetBorder(true).
  15. SetBorderPadding(0, 0, 1, 0)
  16. return i
  17. }