Перевод обработчиков нажатия клавиш со строк на объект клавиш, комментарии
This commit is contained in:
parent
c69a7ae84b
commit
2192b3647f
11 changed files with 240 additions and 210 deletions
|
|
@ -3,6 +3,7 @@ package fields
|
|||
import (
|
||||
"bubble/types"
|
||||
"fmt"
|
||||
"github.com/charmbracelet/bubbles/key"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
|
|
@ -36,9 +37,9 @@ func (m *CheckboxModel) Update(msg tea.Msg) (FieldModel, tea.Cmd) {
|
|||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
//Отслеживает нажатия клавиш.
|
||||
switch msg.String() {
|
||||
case "enter":
|
||||
//Если был нажат enter, то меняем текущее значение на противоположное
|
||||
switch {
|
||||
case key.Matches(msg, types.MainKeys.Confirm):
|
||||
//Если была нажата клавиша подтверждения, то меняем текущее значение на противоположное
|
||||
m.checked = !m.checked
|
||||
m.CheckboxValidate()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue