From ab9787fbf42c41200a3060035a823c82c79ef68b Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 22 Aug 2014 01:14:05 +0100 Subject: Fixes bug #162 (Home/End doesn't move cell focus is smoothscroll StringGrid) --- src/gui/fpg_basegrid.pas | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index cbce739f..be23f8c8 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -1504,6 +1504,7 @@ procedure TfpgBaseGrid.FollowFocus; var n: Integer; w: TfpgCoord; + lmin, lmax: TfpgCoord; begin if (RowCount > 0) and (FFocusRow < 0) then FFocusRow := 0; @@ -1546,6 +1547,19 @@ begin end; end; { for } end; { if/else } + + // If smoothscroll, convert FFirstCol to X Offset value + if go_SmoothScroll in FOptions then + begin + w := 0; + for n := 0 to FFocusCol-1 do + w := w + ColumnWidth[n]; + lmin := FXOffset; + lmax := FXOffset + VisibleWidth; + if (w > lmax) or (w < lmin) then + FXOffset := w; + end; + CheckFocusChange; UpdateScrollBars; end; -- cgit v1.2.3-70-g09d2