Skip to content

Commit

Permalink
demo must handle KeyDown
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey-T committed Dec 15, 2023
1 parent 23f49fa commit 8e7ab88
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/demo_simple/project1.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
Expand Down
6 changes: 4 additions & 2 deletions app/demo_simple/unit1.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ object Form1: TForm1
Caption = 'Simple completion demo'
ClientHeight = 327
ClientWidth = 671
OnShow = FormShow
KeyPreview = True
Position = poScreenCenter
LCLVersion = '2.3.0.0'
LCLVersion = '3.99.0.0'
OnKeyDown = FormKeyDown
OnShow = FormShow
object Panel1: TPanel
Left = 0
Height = 50
Expand Down
10 changes: 10 additions & 0 deletions app/demo_simple/unit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ TForm1 = class(TForm)
var AHandled: boolean);
procedure EdKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormShow(Sender: TObject);
private
procedure DoCompletionProp(Sender: TObject;
Expand Down Expand Up @@ -94,5 +95,14 @@ procedure TForm1.EdKeyDown(Sender: TObject; var Key: Word;
Ed.DoCommand(cmd_AutoComplete, TATCommandInvoke.AppInternal);
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Assigned(FormAutoCompletion) and FormAutoCompletion.Visible then
begin
FormAutoCompletion.FormKeyDown(Sender, Key, Shift);
exit;
end;
end;

end.

0 comments on commit 8e7ab88

Please sign in to comment.