From b55202b53d73ea58e7ec050191e9a6380fd38275 Mon Sep 17 00:00:00 2001 From: graemeg Date: Mon, 8 Sep 2008 13:45:29 +0000 Subject: * TfpgBaseGrid's FocusCol and FocusRow now defaults to -1 --- src/gui/gui_basegrid.pas | 8 ++++---- src/gui/gui_customgrid.pas | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gui/gui_basegrid.pas b/src/gui/gui_basegrid.pas index 98d4359b..aa9cc0b9 100644 --- a/src/gui/gui_basegrid.pas +++ b/src/gui/gui_basegrid.pas @@ -129,8 +129,8 @@ type property FontDesc: string read GetFontDesc write SetFontDesc; property HeaderFont: TfpgFont read FHeaderFont; property HeaderFontDesc: string read GetHeaderFontDesc write SetHeaderFontDesc; - property FocusCol: Integer read FFocusCol write SetFocusCol; - property FocusRow: Integer read FFocusRow write SetFocusRow; + property FocusCol: Integer read FFocusCol write SetFocusCol default -1; + property FocusRow: Integer read FFocusRow write SetFocusRow default -1; property RowSelect: boolean read FRowSelect write SetRowSelect; property ColumnCount: Integer read GetColumnCount; property RowCount: Integer read GetRowCount; @@ -1093,9 +1093,9 @@ begin Focusable := True; Width := 120; Height := 80; - FFocusCol := 0; + FFocusCol := -1; FPrevCol := -1; - FFocusRow := 0; + FFocusRow := -1; FPrevRow := -1; FFirstRow := 0; FFirstCol := 0; diff --git a/src/gui/gui_customgrid.pas b/src/gui/gui_customgrid.pas index 0efa0edb..7b5aa52f 100644 --- a/src/gui/gui_customgrid.pas +++ b/src/gui/gui_customgrid.pas @@ -64,6 +64,7 @@ type protected FRowCount: Integer; FColumns: TList; + procedure HandleSetFocus; override; procedure SetTextColor(const AValue: TfpgColor); override; function GetColumns(AIndex: integer): TfpgGridColumn; virtual; procedure DoDeleteColumn(ACol: integer); virtual; @@ -114,6 +115,17 @@ begin Result := FRowCount; end; +procedure TfpgCustomGrid.HandleSetFocus; +begin + inherited HandleSetFocus; + if (GetRowCount > 0) and (FocusRow = -1) then + begin + FocusRow := 0; + FocusCol := 0; + Repaint; + end; +end; + procedure TfpgCustomGrid.SetTextColor(const AValue: TfpgColor); var i: integer; -- cgit v1.2.3-70-g09d2