From 5cae5042991767c47d706c7716d7791421bd8507 Mon Sep 17 00:00:00 2001 From: wellcomez Date: Fri, 25 Oct 2024 15:20:39 +0800 Subject: [PATCH 1/2] Update list.go mouse click no need adjust offset. adjust offset will cause listbox jump to wrong place --- list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list.go b/list.go index 8da65666..8ae2a14b 100644 --- a/list.go +++ b/list.go @@ -710,7 +710,7 @@ func (l *List) MouseHandler() func(action MouseAction, event *tcell.EventMouse, if l.changed != nil { l.changed(index, item.MainText, item.SecondaryText, item.Shortcut) } - l.adjustOffset() + //l.adjustOffset() } l.currentItem = index } From 8f83d32bf3dd803e294697d3c09f48fe2cfd76ec Mon Sep 17 00:00:00 2001 From: wellcomez Date: Fri, 25 Oct 2024 15:36:01 +0800 Subject: [PATCH 2/2] wrong tree scroll --- treeview.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/treeview.go b/treeview.go index d4b19675..9dddef49 100644 --- a/treeview.go +++ b/treeview.go @@ -843,6 +843,37 @@ func (t *TreeView) MouseHandler() func(action MouseAction, event *tcell.EventMou switch action { case MouseLeftDown: setFocus(t) + // You should make logic more complex here. + + + // 1. after scroll end, offsetY will change to "Y" + // 2. at this time selection index not set to mouse click point, it still out of view + // 3. after click event, tree will draw again. + + + // 4. draw will call 'process', process will change offsetY back to previous + // 5. after that, offsetY is wrong, at click event + // y += t.offsetY - rectY + // still use old value . click will jump to node which doesn't user except + + + // from 624- 637 + //if t.movement != treeScroll { + // if selectedIndex-t.offsetY >= height { + // t.offsetY = selectedIndex - height + 1 + // } + // if selectedIndex < t.offsetY { + // t.offsetY = selectedIndex + // } + // if t.movement != treeHome && t.movement != treeEnd { + // // treeScroll, treeHome, and treeEnd are handled by Draw(). + // t.movement = treeNone + // t.step = 0 + // } + //} + + + consumed = true case MouseLeftClick: _, rectY, _, _ := t.GetInnerRect()