From 8721e9bc9ff7f719edfb0fb1d0d927bc2c4dba40 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 6 Aug 2020 17:39:34 +0200 Subject: ListBox: Fix weird glitch + some cleanup The WM_WINDOWPOSCHANGED handling of WindowBase somehow was messing up. --- listbox.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/listbox.go b/listbox.go index 8ebf8f3a..cf274527 100644 --- a/listbox.go +++ b/listbox.go @@ -166,8 +166,6 @@ func (lb *ListBox) itemString(index int) string { default: return fmt.Sprintf(lb.format, val) } - - panic("unreachable") } //insert one item from list model @@ -263,7 +261,7 @@ func (lb *ListBox) ensureVisibleItemsHeightUpToDate() error { lb.lastWidthsMeasuredFor[i] = lb.lastWidth } - lb.SendMessage(win.LB_SETTOPINDEX, uintptr(topIndex), 0) + lb.EnsureItemVisible(topIndex) return nil } @@ -647,6 +645,8 @@ func (lb *ListBox) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) ui lb.ensureVisibleItemsHeightUpToDate() + return win.CallWindowProc(lb.origWndProcPtr, hwnd, msg, wParam, lParam) + case win.WM_VSCROLL: lb.ensureVisibleItemsHeightUpToDate() @@ -657,6 +657,10 @@ func (lb *ListBox) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) ui lb.Invalidate() case win.WM_MOUSEMOVE: + if lb.styler == nil { + break + } + if !lb.trackingMouseEvent { var tme win.TRACKMOUSEEVENT tme.CbSize = uint32(unsafe.Sizeof(tme)) @@ -696,6 +700,10 @@ func (lb *ListBox) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) ui } case win.WM_MOUSELEAVE: + if lb.styler == nil { + break + } + lb.trackingMouseEvent = false index := lb.style.hoverIndex -- cgit v1.2.3-59-g8ed1b