Enable shortcuts in memo editor:

- Escape for cancel editing
- Ctrl + Enter for apply text and end editing
This commit is contained in:
Ansgar Becker
2008-08-09 19:47:13 +00:00
parent 8c83507561
commit 81609c83cb
2 changed files with 16 additions and 1 deletions

View File

@ -27,5 +27,6 @@ object frmMemoEditor: TfrmMemoEditor
ScrollBars = ssBoth ScrollBars = ssBoth
TabOrder = 0 TabOrder = 0
WantTabs = True WantTabs = True
OnKeyDown = memoTextKeyDown
end end
end end

View File

@ -3,7 +3,7 @@ unit memoeditor;
interface interface
uses uses
Windows, Classes, Graphics, Controls, Forms, StdCtrls, TntStdCtrls, Registry; Windows, Classes, Graphics, Controls, Forms, StdCtrls, TntStdCtrls, Registry, VirtualTrees;
{$I const.inc} {$I const.inc}
@ -12,6 +12,7 @@ type
memoText: TTntMemo; memoText: TTntMemo;
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure memoTextKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private private
{ Private declarations } { Private declarations }
public public
@ -58,5 +59,18 @@ begin
end; end;
procedure TfrmMemoEditor.memoTextKeyDown(Sender: TObject; var Key: Word; Shift:
TShiftState);
var
Tree: TCustomVirtualStringTree;
begin
Tree := TCustomVirtualStringTree(Parent);
case Key of
// Cancel by Escape
VK_ESCAPE: Tree.CancelEditNode;
// Apply changes and end editing by Ctrl + Enter
VK_RETURN: if ssCtrl in Shift then Tree.EndEditNode;
end;
end;
end. end.