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
FWorkbookSource: TsWorkbookSource;
FShowHTMLText: Boolean;
FOldText: String;
function GetSelectedCell: PCell;
function GetWorkbook: TsWorkbook;
function GetWorksheet: TsWorksheet;
procedure SetWorkbookSource(AValue: TsWorkbookSource);
protected
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure ShowCell(ACell: PCell); virtual;
public
@ -1854,6 +1856,23 @@ begin
Result := nil;
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
of the spreadsheet has changed.
@ -1962,6 +1981,7 @@ begin
end;
end else
Clear;
FOldText := Lines.Text;
end;