Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove adjust offset on mouse click #1043

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
31 changes: 31 additions & 0 deletions treeview.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down