You've already forked lazarus-ccr
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:
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user