fix(tracker): unit search gains focus when adding a unit on last row

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-09-07 21:29:37 +03:00
parent 877556b428
commit 6fc9277113
5 changed files with 68 additions and 52 deletions

View File

@ -41,7 +41,20 @@ func (v *FilePath) change(kind string) func() { return func() {} }
// UnitSearchString
func (v *UnitSearch) String() String { return String{v} }
func (v *UnitSearch) Value() string { return v.d.UnitSearchString }
func (v *UnitSearch) Value() string {
// return current unit type string if not searching
if !v.d.UnitSearching {
if v.d.InstrIndex < 0 || v.d.InstrIndex >= len(v.d.Song.Patch) {
return ""
}
if v.d.UnitIndex < 0 || v.d.UnitIndex >= len(v.d.Song.Patch[v.d.InstrIndex].Units) {
return ""
}
return v.d.Song.Patch[v.d.InstrIndex].Units[v.d.UnitIndex].Type
} else {
return v.d.UnitSearchString
}
}
func (v *UnitSearch) setValue(value string) {
v.d.UnitSearchString = value
v.d.UnitSearching = true