mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 11:19:31 +02:00
LCL, grids: Fix dbgrid header click issue #28919
git-svn-id: trunk@52617 -
This commit is contained in:
parent
dac8469d9c
commit
af0ed1ee21
@ -371,6 +371,7 @@ type
|
|||||||
function NeedAutoSizeColumns: boolean;
|
function NeedAutoSizeColumns: boolean;
|
||||||
procedure RenewColWidths;
|
procedure RenewColWidths;
|
||||||
procedure InternalAutoSizeColumn(aCol: Integer; aCanvas: TCanvas; aDatalinkActive: Boolean);
|
procedure InternalAutoSizeColumn(aCol: Integer; aCanvas: TCanvas; aDatalinkActive: Boolean);
|
||||||
|
procedure DoHeaderClick(Index: Integer);
|
||||||
protected
|
protected
|
||||||
procedure AddAutomaticColumns;
|
procedure AddAutomaticColumns;
|
||||||
procedure AssignTo(Dest: TPersistent); override;
|
procedure AssignTo(Dest: TPersistent); override;
|
||||||
@ -824,6 +825,17 @@ begin
|
|||||||
ColWidths[0]:=12;
|
ColWidths[0]:=12;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomDBGrid.DoHeaderClick(Index: Integer);
|
||||||
|
var
|
||||||
|
Column: TColumn;
|
||||||
|
begin
|
||||||
|
if Assigned(OnTitleClick) then begin
|
||||||
|
Column := TColumn(ColumnFromGridColumn(Index));
|
||||||
|
if Column <> nil then
|
||||||
|
OnTitleClick(Column);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomDBGrid.GetColumns: TDBGridColumns;
|
function TCustomDBGrid.GetColumns: TDBGridColumns;
|
||||||
begin
|
begin
|
||||||
result := TDBGridColumns( inherited Columns );
|
result := TDBGridColumns( inherited Columns );
|
||||||
@ -2175,17 +2187,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDBGrid.HeaderClick(IsColumn: Boolean; index: Integer);
|
procedure TCustomDBGrid.HeaderClick(IsColumn: Boolean; index: Integer);
|
||||||
var
|
|
||||||
Column: TColumn;
|
|
||||||
begin
|
begin
|
||||||
{$ifdef dbgDBGrid}
|
{$ifdef dbgDBGrid}
|
||||||
DebugLn('%s.HeaderClick', [ClassName]);
|
DebugLn('%s.HeaderClick', [ClassName]);
|
||||||
{$endif}
|
{$endif}
|
||||||
if Assigned(OnTitleClick) and IsColumn then begin
|
if IsColumn then
|
||||||
Column := TColumn(ColumnFromGridColumn(Index));
|
DoHeaderClick(Index);
|
||||||
if Column<>nil then
|
|
||||||
OnTitleClick(Column);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDBGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
procedure TCustomDBGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
@ -2807,16 +2814,18 @@ begin
|
|||||||
if Button<>mbLeft then
|
if Button<>mbLeft then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if (aCol>=FirstGridColumn)and(aRow>=FixedRows) then
|
if (aCol>=FirstGridColumn) then begin
|
||||||
begin
|
if (aRow>=FixedRows) then begin
|
||||||
if IsColumnVisible(aCol) and
|
if IsColumnVisible(aCol) and
|
||||||
(ColumnEditorStyle(ACol, SelectedField) = cbsCheckboxColumn) then begin
|
(ColumnEditorStyle(ACol, SelectedField) = cbsCheckboxColumn) then begin
|
||||||
// react only if overriden editor is hidden
|
// react only if overriden editor is hidden
|
||||||
if (Editor=nil) or not EditorMode then
|
if (Editor=nil) or not EditorMode then
|
||||||
SwapCheckBox
|
SwapCheckBox
|
||||||
end;
|
end;
|
||||||
if Assigned(OnCellClick) then
|
if Assigned(OnCellClick) then
|
||||||
OnCellClick(TColumn(ColumnFromGridColumn(aCol)));
|
OnCellClick(TColumn(ColumnFromGridColumn(aCol)));
|
||||||
|
end else
|
||||||
|
DoHeaderClick(aCol)
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user