inputfields.go 657 B

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