You've already forked lazarus-ccr
fpspreadsheet: Fix broken transfer of TsCellEdit content to the grid by clicking on the grid.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6540 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -262,6 +262,7 @@ type
|
|||||||
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
procedure ShowCell(ACell: PCell); virtual;
|
procedure ShowCell(ACell: PCell); virtual;
|
||||||
|
procedure WriteToCell;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -1953,12 +1954,13 @@ var
|
|||||||
err: String;
|
err: String;
|
||||||
begin
|
begin
|
||||||
Result := ValidFormula(AText, err);
|
Result := ValidFormula(AText, err);
|
||||||
if not Result then begin
|
Worksheet.SelectCell(FRefocusingRow, FRefocusingCol);
|
||||||
Worksheet.SelectCell(FRefocusingRow, FRefocusingCol);
|
Text := AText; // restore orig text lost by interaction with grid
|
||||||
Text := AText; // restore orig text lost by interaction with grid
|
SelStart := FRefocusingSelStart;
|
||||||
SelStart := FRefocusingSelStart;
|
if Result then
|
||||||
|
WriteToCell
|
||||||
|
else
|
||||||
MessageDlg(err, mtError, [mbOK], 0);
|
MessageDlg(err, mtError, [mbOK], 0);
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@ -1970,7 +1972,6 @@ end;
|
|||||||
procedure TsCellEdit.EditingDone;
|
procedure TsCellEdit.EditingDone;
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
cell: PCell;
|
|
||||||
begin
|
begin
|
||||||
if (Worksheet = nil) then
|
if (Worksheet = nil) then
|
||||||
exit;
|
exit;
|
||||||
@ -1980,14 +1981,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
cell := Worksheet.GetCell(Worksheet.ActiveCellRow, Worksheet.ActiveCellCol);
|
WriteToCell;
|
||||||
if Worksheet.IsMerged(cell) then
|
|
||||||
cell := Worksheet.FindMergeBase(cell);
|
|
||||||
s := Lines.Text;
|
|
||||||
if (s <> '') and (s[1] = '=') then
|
|
||||||
Worksheet.WriteFormula(cell, Copy(s, 2, Length(s)), true)
|
|
||||||
else
|
|
||||||
Worksheet.WriteCellValueAsString(cell, s);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
@ -2239,6 +2233,25 @@ begin
|
|||||||
// here.
|
// here.
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Writes the current edit text to the cell
|
||||||
|
Note: All validation checks already have been performed.
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsCellEdit.WriteToCell;
|
||||||
|
var
|
||||||
|
cell: PCell;
|
||||||
|
s: String;
|
||||||
|
begin
|
||||||
|
cell := Worksheet.GetCell(Worksheet.ActiveCellRow, Worksheet.ActiveCellCol);
|
||||||
|
if Worksheet.IsMerged(cell) then
|
||||||
|
cell := Worksheet.FindMergeBase(cell);
|
||||||
|
s := Lines.Text;
|
||||||
|
if (s <> '') and (s[1] = '=') then
|
||||||
|
Worksheet.WriteFormula(cell, Copy(s, 2, Length(s)), true)
|
||||||
|
else
|
||||||
|
Worksheet.WriteCellValueAsString(cell, s);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------}
|
{------------------------------------------------------------------------------}
|
||||||
{ TsCellIndicator }
|
{ TsCellIndicator }
|
||||||
|
Reference in New Issue
Block a user