From 46056e54e40eeaecd3e5cc8cd422cf3ca3554501 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 17 Nov 2014 22:52:15 -0500 Subject: [PATCH] Added a prev parameter to finishSelect() on the new Windows Table. This will allow proper scrolling to the selection. --- wintable/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wintable/main.c b/wintable/main.c index 826fe30..01a0a40 100644 --- a/wintable/main.c +++ b/wintable/main.c @@ -333,7 +333,7 @@ static void recomputeHScroll(struct table *t) SetScrollInfo(t->hwnd, SB_HORZ, &si, TRUE); } -static void finishSelect(struct table *t) +static void finishSelect(struct table *t, intptr_t prev) { if (t->selected < 0) t->selected = 0; @@ -346,9 +346,12 @@ static void finishSelect(struct table *t) static void keySelect(struct table *t, WPARAM wParam, LPARAM lParam) { + intptr_t prev; + // TODO figure out correct behavior with nothing selected if (t->count == 0) // don't try to do anything if there's nothing to do return; + prev = t->selected; switch (wParam) { case VK_UP: t->selected--; @@ -389,14 +392,16 @@ static void keySelect(struct table *t, WPARAM wParam, LPARAM lParam) // don't touch anything return; } - finishSelect(t); + finishSelect(t, prev); } static void selectItem(struct table *t, WPARAM wParam, LPARAM lParam) { int x, y; LONG h; + intptr_t prev; + prev = t->selected; x = GET_X_LPARAM(lParam); y = GET_Y_LPARAM(lParam); h = rowHeight(t); @@ -407,7 +412,7 @@ static void selectItem(struct table *t, WPARAM wParam, LPARAM lParam) if (t->selected >= t->count) t->selected = -1; t->focusedColumn = hitTestColumn(t, x); - finishSelect(t); + finishSelect(t, prev); } static void vscrollto(struct table *t, intptr_t newpos)