Strange. With LCL-GTK3 a Form.OnKeyDown handler is not called.
The test app from issue :
 https://bugs.freepascal.org/view.php?id=37073
can be used. It has a splashscreen but have tested with a normal form,
too. Same effect.

The attached patch takes out a test
  if Widget^.has_focus then
in function Gtk3WidgetEvent(). Then an OnKeyDown handler is called twice.
Strangely enough, debugger shows the following line
  Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, True);
is called at least sometimes even when the Widget^.has_focus test is there.
The message is delivered somewhere but not to the form.
GTK3 experts, do you know what is going on?

Juha
From 26ea6e9395387d117fb81105c2cec15e6e067c6f Mon Sep 17 00:00:00 2001
From: Juha <juha.mannine...@gmail.com>
Date: Sat, 16 May 2020 20:39:28 +0300
Subject: [PATCH] LCL-GTK3: Make TForm.OnKeyDown work.

---
 lcl/interfaces/gtk3/gtk3widgets.pas | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lcl/interfaces/gtk3/gtk3widgets.pas b/lcl/interfaces/gtk3/gtk3widgets.pas
index dd54483fa..d4f834619 100644
--- a/lcl/interfaces/gtk3/gtk3widgets.pas
+++ b/lcl/interfaces/gtk3/gtk3widgets.pas
@@ -1224,13 +1224,13 @@ begin
     // GDK_KEY_PRESS
     8:
     begin
-      if Widget^.has_focus then
+      //if Widget^.has_focus then
         Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, True);
     end;
     // GDK_KEY_RELEASE
     9:
     begin
-      if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
+      //if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
         Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, False);
     end;
 
-- 
2.26.2

-- 
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to