summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpg_main.pas2
-rw-r--r--src/corelib/fpg_widget.pas18
2 files changed, 19 insertions, 1 deletions
diff --git a/src/corelib/fpg_main.pas b/src/corelib/fpg_main.pas
index 0e2f5384..a83c5590 100644
--- a/src/corelib/fpg_main.pas
+++ b/src/corelib/fpg_main.pas
@@ -229,6 +229,7 @@ type
FHintTimer: TfpgTimer;
FHintWidget: TfpgWindow;
FHintPos: TPoint;
+ FOnKeyPress: TKeyPressEvent;
procedure SetHintPause(const AValue: Integer);
procedure SetupLocalizationStrings;
procedure InternalMsgFreeMe(var msg: TfpgMessageRec); message FPGM_FREEME;
@@ -270,6 +271,7 @@ type
property ShowHint: boolean read FShowHint write SetShowHint default True;
property StopOnException: Boolean read FStopOnException write FStopOnException;
property OnException: TExceptionEvent read FOnException write FOnException;
+ property OnKeyPress: TKeyPressEvent read FOnKeyPress write FOnKeyPress;
end;
diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas
index 1d51a7ad..4e48aa75 100644
--- a/src/corelib/fpg_widget.pas
+++ b/src/corelib/fpg_widget.pas
@@ -179,7 +179,8 @@ implementation
uses
fpg_constants,
- fpg_menu;
+ fpg_menu,
+ fpg_form; { for OnKeyPress handling }
var
@@ -475,6 +476,7 @@ var
ss: TShiftState;
consumed: boolean;
wg: TfpgWidget;
+ wlast: TfpgWidget;
begin
if InDesigner then
begin
@@ -490,13 +492,27 @@ begin
HandleKeyPress(key, ss, consumed);
if not consumed then
begin
+ { work it's way to one before top level form - forms are not focusable remember }
wg := Parent;
+ wlast := wg;
while (not consumed) and (wg <> nil) do
begin
wg.HandleKeyPress(key, ss, consumed);
+ wlast := wg;
wg := wg.Parent;
end;
end;
+ { we should now be at the top level form }
+ if (not consumed) and (wlast <> nil) then
+ begin
+ if (wlast is TfpgForm) and Assigned(wlast.OnKeyPress) then
+ wlast.OnKeyPress(self, key, ss, consumed);
+ end;
+ { now finaly, lets give fpgApplication a chance }
+ if (not consumed) and Assigned(fpgApplication.OnKeyPress) then
+ begin
+ fpgApplication.OnKeyPress(self, key, ss, consumed);
+ end;
end;
procedure TfpgWidget.MsgKeyRelease(var msg: TfpgMessageRec);