added Application OnKeyDownHandler

git-svn-id: trunk@4042 -
This commit is contained in:
mattias 2003-04-11 10:23:23 +00:00
parent 280af8c739
commit 36bdb823f4
2 changed files with 36 additions and 1 deletions

View File

@ -625,6 +625,7 @@ type
FOnIdleHandler: TMethodList;
FOnIdleEnd: TNotifyEvent;
FOnIdleEndHandler: TMethodList;
FOnKeyDownHandler: TMethodList;
FOnShowHint: TShowHintEvent;
FOnUserInput: TOnUserInputEvent;
FOnUserInputHandler: TMethodList;
@ -682,12 +683,15 @@ type
procedure ShowException(E: Exception);
procedure Terminate;
procedure NotifyUserInputHandler(Msg: Cardinal);
procedure NotifyKeyDownHandler(var Key : Word; Shift : TShiftState);
procedure AddOnIdleHandler(AnOnIdleHandler: TNotifyEvent);
procedure RemoveOnIdleHandler(AnOnIdleHandler: TNotifyEvent);
procedure AddOnIdleEndHandler(AnOnIdleEndHandler: TNotifyEvent);
procedure RemoveOnIdleEndHandler(AnOnIdleEndHandler: TNotifyEvent);
procedure AddOnUserInputHandler(AnOnUserInputHandler: TOnUserInputEvent);
procedure RemoveOnUserInputHandler(AnOnUserInputHandler: TOnUserInputEvent);
procedure AddOnKeyDownHandler(AnOnKeyDownHandler: TKeyEvent);
procedure RemoveOnKeyDownHandler(AnOnKeyDownHandler: TKeyEvent);
procedure DoBeforeMouseMessage(CurMouseControl: TControl);
public
property Exename: String read GetExeName;

View File

@ -102,6 +102,7 @@ begin
FreeThenNil(FOnIdleHandler);
FreeThenNil(FOnIdleEndHandler);
FreeThenNil(FOnUserInputHandler);
FreeThenNil(FOnKeyDownHandler);
inherited Destroy;
LCLProc.SendApplicationMessageFunction:=nil;
end;
@ -134,7 +135,7 @@ end;
{------------------------------------------------------------------------------
TApplication GetExename
------------------------------------------------------------------------------}
Function TApplication.GetEXEName: String;
Function TApplication.GetExeName: String;
Begin
Result := ParamStr(0);
end;
@ -858,6 +859,20 @@ begin
end;
end;
procedure TApplication.NotifyKeyDownHandler(var Key: Word; Shift: TShiftState);
var
i: Integer;
begin
if FOnKeyDownHandler=nil then exit;
i:=FOnKeyDownHandler.Count-1;
while (i>=0) and (FOnKeyDownHandler<>nil) and (Key<>VK_UNKNOWN) do begin
TKeyEvent(FOnKeyDownHandler[i])(Self,Key,Shift);
dec(i);
if (FOnKeyDownHandler<>nil) and (i>FOnKeyDownHandler.Count-1) then
i:=FOnKeyDownHandler.Count-1;
end;
end;
procedure TApplication.AddOnIdleHandler(AnOnIdleHandler: TNotifyEvent);
begin
if FOnIdleHandler=nil then
@ -899,6 +914,19 @@ begin
FOnUserInputHandler.Remove(TMethod(AnOnUserInputHandler));
end;
procedure TApplication.AddOnKeyDownHandler(AnOnKeyDownHandler: TKeyEvent);
begin
if FOnKeyDownHandler=nil then
FOnKeyDownHandler:=TMethodList.Create;
FOnKeyDownHandler.Add(TMethod(AnOnKeyDownHandler));
end;
procedure TApplication.RemoveOnKeyDownHandler(AnOnKeyDownHandler: TKeyEvent);
begin
if FOnKeyDownHandler<>nil then
FOnKeyDownHandler.Remove(TMethod(AnOnKeyDownHandler));
end;
{------------------------------------------------------------------------------
procedure TApplication.DoBeforeMouseMessage(CurMouseControl: TControl);
------------------------------------------------------------------------------}
@ -963,6 +991,9 @@ end;
{ =============================================================================
$Log$
Revision 1.49 2003/04/11 10:23:23 mattias
added Application OnKeyDownHandler
Revision 1.48 2003/04/11 09:32:20 mattias
added some help stuff