Actually return no selection in clientCoordToRowColumn() correctly. Part 2 of previous commit.
This commit is contained in:
parent
b9c46d4cdf
commit
e31fd24a99
|
@ -39,19 +39,17 @@ static struct rowcol clientCoordToRowColumn(struct table *t, POINT pt)
|
|||
struct rowcol rc;
|
||||
intptr_t i;
|
||||
|
||||
// initial values for the PtInRect() check
|
||||
rc.row = -1;
|
||||
rc.column = -1;
|
||||
|
||||
if (GetClientRect(t->hwnd, &r) == 0)
|
||||
panic("error getting Table client rect in clientCoordToRowColumn()");
|
||||
r.top += t->headerHeight;
|
||||
if (PtInRect(&r, pt) == 0)
|
||||
return rc;
|
||||
goto outside;
|
||||
|
||||
// the row is easy
|
||||
pt.y -= t->headerHeight;
|
||||
rc.row = (pt.y / rowht(t)) + t->vscrollpos;
|
||||
if (rc.row >= t->count)
|
||||
goto outside;
|
||||
|
||||
// the column... not so much
|
||||
// we scroll p.x, then subtract column widths until we cross the left edge of the control
|
||||
|
@ -69,9 +67,15 @@ static struct rowcol clientCoordToRowColumn(struct table *t, POINT pt)
|
|||
break;
|
||||
rc.column++;
|
||||
}
|
||||
// TODO what happens if the break was never taken?
|
||||
if (rc.column >= t->nColumns)
|
||||
goto outside;
|
||||
|
||||
return rc;
|
||||
|
||||
outside:
|
||||
rc.row = -1;
|
||||
rc.column = -1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
// same as client coordinates, but stored in a lParam (like the various mouse messages provide)
|
||||
|
|
Loading…
Reference in New Issue