fpspreadsheet: Restore old cell content if ESC is pressed in the TsCellEdit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5213 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-09-25 21:50:51 +00:00
parent 4a1bea77f7
commit a85bda5f5d

View File

@ -233,11 +233,13 @@ type
private private
FWorkbookSource: TsWorkbookSource; FWorkbookSource: TsWorkbookSource;
FShowHTMLText: Boolean; FShowHTMLText: Boolean;
FOldText: String;
function GetSelectedCell: PCell; function GetSelectedCell: PCell;
function GetWorkbook: TsWorkbook; function GetWorkbook: TsWorkbook;
function GetWorksheet: TsWorksheet; function GetWorksheet: TsWorksheet;
procedure SetWorkbookSource(AValue: TsWorkbookSource); procedure SetWorkbookSource(AValue: TsWorkbookSource);
protected protected
procedure KeyDown(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;
public public
@ -1854,6 +1856,23 @@ begin
Result := nil; Result := nil;
end; end;
{@@ ----------------------------------------------------------------------------
Inherited KeyDown method. Overridden here in order to be able to restore the
old cell content if ESC is pressed.
-------------------------------------------------------------------------------}
procedure TsCellEdit.KeyDown(var Key: Word; Shift : TShiftState);
var
selpos: Integer;
begin
if Key = VK_ESCAPE then begin
selpos := SelStart;
Lines.Text := FOldText;
SelStart := selpos;
exit;
end;
inherited;
end;
{@@ ---------------------------------------------------------------------------- {@@ ----------------------------------------------------------------------------
Notification message received from the WorkbookSource telling which item Notification message received from the WorkbookSource telling which item
of the spreadsheet has changed. of the spreadsheet has changed.
@ -1962,6 +1981,7 @@ begin
end; end;
end else end else
Clear; Clear;
FOldText := Lines.Text;
end; end;