Add SetSelection function for list contexts and use it in most places

The only time we should call SetSelectedLineIdx is when we are happy for a
select range to be retained which means things like moving the selected line
index to top top/bottom or up/down a page as the user navigates.

But in every other case we should now call SetSelection because that will
set the selected index and cancel the range which is almost always what we
want.
This commit is contained in:
Jesse Duffield 2024-01-14 09:50:52 +11:00
parent 8840c1a2b7
commit 54bd94ad24
27 changed files with 54 additions and 35 deletions

View file

@ -102,7 +102,7 @@ func (self *ListContextTrait) HandleRender() error {
}
func (self *ListContextTrait) OnSearchSelect(selectedLineIdx int) error {
self.GetList().SetSelectedLineIdx(selectedLineIdx)
self.GetList().SetSelection(selectedLineIdx)
return self.HandleFocus(types.OnFocusOpts{})
}