From 781f516d441316587e8d219b412c0514ed68ff84 Mon Sep 17 00:00:00 2001 From: Joe Kralicky Date: Tue, 10 Sep 2024 11:39:59 -0400 Subject: [PATCH] Add Cursor() methods to Select and MultiSelect fields --- field_multiselect.go | 5 +++++ field_select.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/field_multiselect.go b/field_multiselect.go index faa33ee5..c0b43044 100644 --- a/field_multiselect.go +++ b/field_multiselect.go @@ -220,6 +220,11 @@ func (m *MultiSelect[T]) Blur() tea.Cmd { return nil } +// Cursor returns the position of the cursor within the multi-select. +func (m *MultiSelect[T]) Cursor() int { + return m.cursor +} + // KeyBinds returns the help message for the multi-select field. func (m *MultiSelect[T]) KeyBinds() []key.Binding { binds := []key.Binding{ diff --git a/field_select.go b/field_select.go index 81e57d9e..f32f415c 100644 --- a/field_select.go +++ b/field_select.go @@ -281,6 +281,11 @@ func (s *Select[T]) Blur() tea.Cmd { return nil } +// Cursor returns the position of the cursor within the select field. +func (m *Select[T]) Cursor() int { + return m.selected +} + // KeyBinds returns the help keybindings for the select field. func (s *Select[T]) KeyBinds() []key.Binding { return []key.Binding{