diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-07-27 15:00:08 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-07-27 15:00:08 +0200 |
commit | 78371edac0335382a9dfd3d4c8d789766fcd8e91 (patch) | |
tree | ff85dcc1503b32d95637fc16a377feb0c236cfc6 | |
parent | 68c45f069b28c1abd487f7c42387fa6ed445ac63 (diff) | |
download | fpGUI-78371edac0335382a9dfd3d4c8d789766fcd8e91.tar.xz |
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.
-rw-r--r-- | src/gui/fpg_basegrid.pas | 28 |
1 files changed, 20 insertions, 8 deletions
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; |