diff --git a/internal/page/proclamationOptions.go b/internal/page/proclamationOptions.go index 11f7155..52844ab 100644 --- a/internal/page/proclamationOptions.go +++ b/internal/page/proclamationOptions.go @@ -54,6 +54,8 @@ type ProclamationOptions struct { indentSize float32 verticalMargin int32 + + isSearchActive bool } func (p *ProclamationOptions) Init(ctx *PageCtx) error { @@ -62,6 +64,7 @@ func (p *ProclamationOptions) Init(ctx *PageCtx) error { p.activeMap = make(map[string]bool) p.allItems = []*FlatItem{} p.scrollOffset = 0 + p.isSearchActive = false p.scrollTrackWidth = 30 p.scrollTrackX = p.ScreenWidth - p.scrollTrackWidth @@ -237,12 +240,21 @@ func (p *ProclamationOptions) HandleEvent(event *sdl.Event) error { } case sdl.K_BACKSPACE, sdl.K_ESCAPE: p.Context.NavigateTo(SETTINGS) + default: + // Treat input as search intent, initiate search & filter + p.toggleTextInput() + p.isSearchActive = true } p.layout() } return nil } +// Turn on and off the text input capture. +// Don't forget to capture the current event, so that you can +// determine which character to start the search with. +func (p *ProclamationOptions) toggleTextInput() {} + func (p *ProclamationOptions) acceptChanges() { p.Context.DbPtr.Transaction(func(tx *gorm.DB) error { tx.Model(&db.Proclamation{}).Where("1 = 1").Update("selected", false)