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

View File

@ -102,6 +102,7 @@ begin
FreeThenNil(FOnIdleHandler); FreeThenNil(FOnIdleHandler);
FreeThenNil(FOnIdleEndHandler); FreeThenNil(FOnIdleEndHandler);
FreeThenNil(FOnUserInputHandler); FreeThenNil(FOnUserInputHandler);
FreeThenNil(FOnKeyDownHandler);
inherited Destroy; inherited Destroy;
LCLProc.SendApplicationMessageFunction:=nil; LCLProc.SendApplicationMessageFunction:=nil;
end; end;
@ -134,7 +135,7 @@ end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TApplication GetExename TApplication GetExename
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
Function TApplication.GetEXEName: String; Function TApplication.GetExeName: String;
Begin Begin
Result := ParamStr(0); Result := ParamStr(0);
end; end;
@ -858,6 +859,20 @@ begin
end; end;
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); procedure TApplication.AddOnIdleHandler(AnOnIdleHandler: TNotifyEvent);
begin begin
if FOnIdleHandler=nil then if FOnIdleHandler=nil then
@ -899,6 +914,19 @@ begin
FOnUserInputHandler.Remove(TMethod(AnOnUserInputHandler)); FOnUserInputHandler.Remove(TMethod(AnOnUserInputHandler));
end; 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); procedure TApplication.DoBeforeMouseMessage(CurMouseControl: TControl);
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
@ -963,6 +991,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.49 2003/04/11 10:23:23 mattias
added Application OnKeyDownHandler
Revision 1.48 2003/04/11 09:32:20 mattias Revision 1.48 2003/04/11 09:32:20 mattias
added some help stuff added some help stuff