From 78371edac0335382a9dfd3d4c8d789766fcd8e91 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Wed, 27 Jul 2011 15:00:08 +0200 Subject: BaseGrid and Home/End key handling and focused cells. We never used to check if we are allowed to set the FFocusCol, we just assumed we are allowed. Now we try each column while calling CanSelectCell() in each iteration so we select the first available column. --- src/gui/fpg_basegrid.pas | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index 1b45cfdf..63537cb0 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -827,6 +827,7 @@ procedure TfpgBaseGrid.HandleKeyPress(var keycode: word; var w: integer; r: integer; + c: integer; begin if consumed then exit; @@ -932,11 +933,17 @@ begin RePaint; end; end - else if (FFocusCol <> 0) and CanSelectCell(FFocusRow, 0) then + else if (FFocusCol <> 0) then begin - FFocusCol := 0; - FollowFocus; - RePaint; + { find first selectable column } + for c := 0 to FFocusCol-1 do + if CanSelectCell(FFocusRow, c) then + begin + FFocusCol := c; + FollowFocus; + RePaint; + break; + end; end; consumed := True; end; @@ -952,11 +959,16 @@ begin RePaint; end; end - else if (FFocusCol <> (ColumnCount-1)) and CanSelectCell(FFocusRow, ColumnCount-1) then + else if (FFocusCol <> (ColumnCount-1)) then begin - FFocusCol := ColumnCount-1; - FollowFocus; - RePaint; + for c := ColumnCount-1 downto FFocusCol+1 do + if CanSelectCell(FFocusRow, c) then + begin + FFocusCol := c; + FollowFocus; + RePaint; + break; + end; end; consumed := True; end; -- cgit v1.2.3-70-g09d2