View Issue Details

IDProjectCategoryView StatusLast Update
0037826LazarusWidgetsetpublic2020-10-05 13:40
ReporterCudaText man_ Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSubuntu 20 x64 
Product Version2.1 (SVN) 
Summary0037826: gtk3: TEdit don't allow all ascii chars
Descriptiondemo
https://github.com/Alexey-T/Lazarus_test_messageboxes

filed "message" don't allow me to enter chars:
& ampersand
( open-bracket
' pascal quote
TagsNo tags attached.
Fixed in Revisionr63948
LazTarget-
WidgetsetGTK 3
Attached Files

Activities

Anton Kavalenka

2020-09-27 21:20

reporter   ~0125909

gtk3widgets.pas:2075

// this is just for testing purposes.
  ACharCode := GdkKeyToLCLKey(KeyValue);
  if KeyValue > VK_UNDEFINED then
    KeyValue := ACharCode; // VK_UNKNOWN;

'&' has code 38
VK_UP has code 38

jamie philbrook

2020-09-27 22:13

reporter   ~0125910

Last edited: 2020-09-27 22:13

View 2 revisions

I am not a gkt expert but I do remember something about the Accel char being in a report and I believe it was for TLabel..

By default it appears to want to show the accel character thus you won't see the "&" because it wants another character to follow so that it can display it as an underlined char..

 Is it possible the same code is being used to refresh the text in a gkt edit box ? if so, this most likely is the issue.. The property to show the accel char needs to be turned off.

Anton Kavalenka

2020-10-03 09:14

reporter   ~0126048

Probably this patch fixes problem.
Plus made some housekeeping in GDK_ constants represention event types
gtk3_key_mess.diff (20,721 bytes)   
Index: lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas	(revision 63942)
+++ lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas	(working copy)
@@ -2625,53 +2625,53 @@
   GDK_GRAB_FROZEN: TGdkGrabStatus = 4;
 
 type
-  TGdkEventType = Integer;
-const
+  TGdkEventType = (
   { GdkEventType }
-  GDK_NOTHING: TGdkEventType = -1;
-  GDK_DELETE: TGdkEventType = 0;
-  GDK_DESTROY: TGdkEventType = 1;
-  GDK_EXPOSE: TGdkEventType = 2;
-  GDK_MOTION_NOTIFY: TGdkEventType = 3;
-  GDK_BUTTON_PRESS: TGdkEventType = 4;
-  GDK_2BUTTON_PRESS: TGdkEventType = 5;
-  GDK_DOUBLE_BUTTON_PRESS: TGdkEventType = 5;
-  GDK_3BUTTON_PRESS: TGdkEventType = 6;
-  GDK_TRIPLE_BUTTON_PRESS: TGdkEventType = 6;
-  GDK_BUTTON_RELEASE: TGdkEventType = 7;
-  GDK_KEY_PRESS: TGdkEventType = 8;
-  GDK_KEY_RELEASE: TGdkEventType = 9;
-  GDK_ENTER_NOTIFY: TGdkEventType = 10;
-  GDK_LEAVE_NOTIFY: TGdkEventType = 11;
-  GDK_FOCUS_CHANGE: TGdkEventType = 12;
-  GDK_CONFIGURE: TGdkEventType = 13;
-  GDK_MAP: TGdkEventType = 14;
-  GDK_UNMAP: TGdkEventType = 15;
-  GDK_PROPERTY_NOTIFY: TGdkEventType = 16;
-  GDK_SELECTION_CLEAR: TGdkEventType = 17;
-  GDK_SELECTION_REQUEST: TGdkEventType = 18;
-  GDK_SELECTION_NOTIFY: TGdkEventType = 19;
-  GDK_PROXIMITY_IN: TGdkEventType = 20;
-  GDK_PROXIMITY_OUT: TGdkEventType = 21;
-  GDK_DRAG_ENTER: TGdkEventType = 22;
-  GDK_DRAG_LEAVE: TGdkEventType = 23;
-  GDK_DRAG_MOTION_: TGdkEventType = 24;
-  GDK_DRAG_STATUS_: TGdkEventType = 25;
-  GDK_DROP_START: TGdkEventType = 26;
-  GDK_DROP_FINISHED: TGdkEventType = 27;
-  GDK_CLIENT_EVENT: TGdkEventType = 28;
-  GDK_VISIBILITY_NOTIFY: TGdkEventType = 29;
-  GDK_SCROLL: TGdkEventType = 31;
-  GDK_WINDOW_STATE: TGdkEventType = 32;
-  GDK_SETTING: TGdkEventType = 33;
-  GDK_OWNER_CHANGE: TGdkEventType = 34;
-  GDK_GRAB_BROKEN: TGdkEventType = 35;
-  GDK_DAMAGE: TGdkEventType = 36;
-  GDK_TOUCH_BEGIN: TGdkEventType = 37;
-  GDK_TOUCH_UPDATE: TGdkEventType = 38;
-  GDK_TOUCH_END: TGdkEventType = 39;
-  GDK_TOUCH_CANCEL: TGdkEventType = 40;
-  GDK_EVENT_LAST: TGdkEventType = 41;
+  GDK_NOTHING = -1,
+  GDK_DELETE = 0,
+  GDK_DESTROY = 1,
+  GDK_EXPOSE = 2,
+  GDK_MOTION_NOTIFY = 3,
+  GDK_BUTTON_PRESS = 4,
+  GDK_2BUTTON_PRESS = 5,
+  GDK_DOUBLE_BUTTON_PRESS = 5,
+  GDK_3BUTTON_PRESS = 6,
+  GDK_TRIPLE_BUTTON_PRESS = 6,
+  GDK_BUTTON_RELEASE = 7,
+  GDK_KEY_PRESS = 8,
+  GDK_KEY_RELEASE = 9,
+  GDK_ENTER_NOTIFY = 10,
+  GDK_LEAVE_NOTIFY = 11,
+  GDK_FOCUS_CHANGE = 12,
+  GDK_CONFIGURE = 13,
+  GDK_MAP = 14,
+  GDK_UNMAP = 15,
+  GDK_PROPERTY_NOTIFY = 16,
+  GDK_SELECTION_CLEAR = 17,
+  GDK_SELECTION_REQUEST = 18,
+  GDK_SELECTION_NOTIFY = 19,
+  GDK_PROXIMITY_IN = 20,
+  GDK_PROXIMITY_OUT = 21,
+  GDK_DRAG_ENTER = 22,
+  GDK_DRAG_LEAVE = 23,
+  GDK_DRAG_MOTION_ = 24,
+  GDK_DRAG_STATUS_ = 25,
+  GDK_DROP_START = 26,
+  GDK_DROP_FINISHED = 27,
+  GDK_CLIENT_EVENT = 28,
+  GDK_VISIBILITY_NOTIFY = 29,
+  GDK_SCROLL = 31,
+  GDK_WINDOW_STATE = 32,
+  GDK_SETTING = 33,
+  GDK_OWNER_CHANGE = 34,
+  GDK_GRAB_BROKEN = 35,
+  GDK_DAMAGE = 36,
+  GDK_TOUCH_BEGIN = 37,
+  GDK_TOUCH_UPDATE = 38,
+  GDK_TOUCH_END = 39,
+  GDK_TOUCH_CANCEL = 40,
+  GDK_EVENT_LAST = 41
+  );
 
 type
   TGdkVisibilityState = Integer;
Index: lcl/interfaces/gtk3/gtk3procs.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3procs.pas	(revision 63942)
+++ lcl/interfaces/gtk3/gtk3procs.pas	(working copy)
@@ -647,10 +647,10 @@
     GDK_KEY_End: Result := VK_END;
     GDK_KEY_Page_Up: Result := VK_PRIOR;
     GDK_KEY_Page_Down: Result := VK_NEXT;
-    GDK_KEY_Left: Result := VK_LEFT;
-    GDK_KEY_Up: Result := VK_UP;
-    GDK_KEY_Right: Result := VK_RIGHT;
-    GDK_KEY_Down: Result := VK_DOWN;
+    GDK_KEY_Left, GDK_KEY_KP_LEFT: Result := VK_LEFT;
+    GDK_KEY_Up, GDK_KEY_KP_UP: Result := VK_UP;
+    GDK_KEY_Right, GDK_KEY_KP_Right: Result := VK_RIGHT;
+    GDK_KEY_Down, GDK_KEY_KP_Down: Result := VK_DOWN;
     GDK_KEY_Menu: Result := VK_APPS;
     GDK_KEY_Tab, GDK_KEY_3270_BackTab, GDK_KEY_ISO_Left_Tab: Result := VK_TAB;
     GDK_KEY_Shift_L, GDK_KEY_Shift_R: Result := VK_SHIFT;
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 63942)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -909,88 +909,47 @@
 begin
   Result := 'GDK_NOTHING';
   case AEvent of
-    // GDK_DELETE:
-    0: Result := 'GDK_DELETE';
-    // GDK_DESTROY:
-    1: Result := 'GDK_DESTROY';
-    // GDK_EXPOSE:
-    2: Result := 'GDK_EXPOSE';
-    // GDK_MOTION_NOTIFY:
-    3: Result := 'GDK_MOTION_NOTIFY';
-    // GDK_BUTTON_PRESS:
-    4: Result := 'GDK_BUTTON_PRESS';
-    // GDK_2BUTTON_PRESS:
-    5: Result := 'GDK_2BUTTON_PRESS';
-    // GDK_3BUTTON_PRESS:
-    6: Result := 'GDK_3BUTTON_PRESS';
-    // GDK_BUTTON_RELEASE:
-    7: Result := 'GDK_BUTTON_RELEASE';
-    // GDK_KEY_PRESS:
-    8: Result := 'GDK_KEY_PRESS';
-    // GDK_KEY_RELEASE:
-    9: Result := 'GDK_KEY_RELEASE';
-    // GDK_ENTER_NOTIFY:
-    10: Result := 'GDK_ENTER_NOTIFY';
-    // GDK_LEAVE_NOTIFY:
-    11: Result := 'GDK_LEAVE_NOTIFY';
-    // GDK_FOCUS_CHANGE:
-    12: Result := 'GDK_FOCUS_CHANGE';
-    // GDK_CONFIGURE:
-    13: Result := 'GDK_CONFIGURE';
-    // GDK_MAP:
-    14: Result := 'GDK_MAP';
-    // GDK_UNMAP:
-    15: Result := 'GDK_UNMAP';
-    // GDK_PROPERTY_NOTIFY:
-    16: Result := 'GDK_PROPERTY_NOTIFY';
-    // GDK_SELECTION_CLEAR:
-    17: Result := 'GDK_SELECTION_CLEAR';
-    // GDK_SELECTION_REQUEST:
-    18: Result := 'GDK_SELECTION_REQUEST';
-    // GDK_SELECTION_NOTIFY:
-    19: Result := 'GDK_SELECTION_NOTIFY';
-    // GDK_PROXIMITY_IN:
-    20: Result := 'GDK_PROXIMITY_IN';
-    // GDK_PROXIMITY_OUT:
-    21: Result := 'GDK_PROXIMITY_OUT';
-    // GDK_DRAG_ENTER:
-    22: Result := 'GDK_DRAG_ENTER';
-    // GDK_DRAG_LEAVE:
-    23: Result := 'GDK_DRAG_LEAVE';
-    // GDK_DRAG_MOTION_:
-    24: Result := 'GDK_DRAG_MOTION_';
-    // GDK_DRAG_STATUS_:
-    25: Result := 'GDK_DRAG_STATUS_';
-    // GDK_DROP_START:
-    26: Result := 'GDK_DROP_START';
-    // GDK_DROP_FINISHED:
-    27: Result := 'GDK_DROP_FINISHED';
-    // GDK_CLIENT_EVENT:
-    28: Result := 'GDK_CLIENT_EVENT';
-    // GDK_VISIBILITY_NOTIFY:
-    29: Result := 'GDK_VISIBILITY_NOTIFY';
-    // GDK_SCROLL:
-    31: Result := 'GDK_SCROLL';
-    // GDK_WINDOW_STATE:
-    32: Result := 'GDK_WINDOW_STATE';
-    // GDK_SETTING:
-    33: Result := 'GDK_SETTING';
-    // GDK_OWNER_CHANGE:
-    34: Result := 'GDK_OWNER_CHANGE';
-    // GDK_GRAB_BROKEN:
-    35: Result := 'GDK_GRAB_BROKEN';
-    // GDK_DAMAGE:
-    36: Result := 'GDK_DAMAGE';
-    // GDK_TOUCH_BEGIN:
-    37: Result := 'GDK_TOUCH_BEGIN';
-    // GDK_TOUCH_UPDATE:
-    38: Result := 'GDK_TOUCH_UPDATE';
-    // GDK_TOUCH_END:
-    39: Result := 'GDK_TOUCH_END';
-    // GDK_TOUCH_CANCEL:
-    40: Result := 'GDK_TOUCH_CANCEL';
-    // GDK_EVENT_LAST:
-    41: Result := 'GDK_EVENT_LAST';
+  GDK_DELETE: Result := 'GDK_DELETE';
+  GDK_DESTROY: Result := 'GDK_DESTROY';
+  GDK_EXPOSE: Result := 'GDK_EXPOSE';
+  GDK_MOTION_NOTIFY: Result := 'GDK_MOTION_NOTIFY';
+  GDK_BUTTON_PRESS: Result := 'GDK_BUTTON_PRESS';
+  GDK_2BUTTON_PRESS: Result := 'GDK_2BUTTON_PRESS';
+  GDK_3BUTTON_PRESS: Result := 'GDK_3BUTTON_PRESS';
+  GDK_BUTTON_RELEASE: Result := 'GDK_BUTTON_RELEASE';
+  GDK_KEY_PRESS: Result := 'GDK_KEY_PRESS';
+  GDK_KEY_RELEASE: Result := 'GDK_KEY_RELEASE';
+  GDK_ENTER_NOTIFY: Result := 'GDK_ENTER_NOTIFY';
+  GDK_LEAVE_NOTIFY: Result := 'GDK_LEAVE_NOTIFY';
+  GDK_FOCUS_CHANGE: Result := 'GDK_FOCUS_CHANGE';
+  GDK_CONFIGURE: Result := 'GDK_CONFIGURE';
+  GDK_MAP: Result := 'GDK_MAP';
+  GDK_UNMAP: Result := 'GDK_UNMAP';
+  GDK_PROPERTY_NOTIFY: Result := 'GDK_PROPERTY_NOTIFY';
+  GDK_SELECTION_CLEAR: Result := 'GDK_SELECTION_CLEAR';
+  GDK_SELECTION_REQUEST: Result := 'GDK_SELECTION_REQUEST';
+  GDK_SELECTION_NOTIFY: Result := 'GDK_SELECTION_NOTIFY';
+  GDK_PROXIMITY_IN: Result := 'GDK_PROXIMITY_IN';
+  GDK_PROXIMITY_OUT: Result := 'GDK_PROXIMITY_OUT';
+  GDK_DRAG_ENTER: Result := 'GDK_DRAG_ENTER';
+  GDK_DRAG_LEAVE: Result := 'GDK_DRAG_LEAVE';
+  GDK_DRAG_MOTION_: Result := 'GDK_DRAG_MOTION_';
+  GDK_DRAG_STATUS_: Result := 'GDK_DRAG_STATUS_';
+  GDK_DROP_START: Result := 'GDK_DROP_START';
+  GDK_DROP_FINISHED: Result := 'GDK_DROP_FINISHED';
+  GDK_CLIENT_EVENT: Result := 'GDK_CLIENT_EVENT';
+  GDK_VISIBILITY_NOTIFY: Result := 'GDK_VISIBILITY_NOTIFY';
+  GDK_SCROLL: Result := 'GDK_SCROLL';
+  GDK_WINDOW_STATE: Result := 'GDK_WINDOW_STATE';
+  GDK_SETTING: Result := 'GDK_SETTING';
+  GDK_OWNER_CHANGE: Result := 'GDK_OWNER_CHANGE';
+  GDK_GRAB_BROKEN: Result := 'GDK_GRAB_BROKEN';
+  GDK_DAMAGE: Result := 'GDK_DAMAGE';
+  GDK_TOUCH_BEGIN: Result := 'GDK_TOUCH_BEGIN';
+  GDK_TOUCH_UPDATE: Result := 'GDK_TOUCH_UPDATE';
+  GDK_TOUCH_END: Result := 'GDK_TOUCH_END';
+  GDK_TOUCH_CANCEL: Result := 'GDK_TOUCH_CANCEL';
+  GDK_EVENT_LAST: Result := 'GDK_EVENT_LAST';
   end;
 end;
 
@@ -1005,18 +964,15 @@
   //  ' ',Gtk3EventToStr(event^.type_));
 
   case event^.type_ of
-    // GDK_DELETE
-    0:
+  GDK_DELETE:
     begin
       // DebugLn('****** GDK_DELETE FOR ',dbgsName(TGtk3Widget(Data).LCLObject),' main_level=',dbgs(gtk_main_level));
     end;
-    // GDK_DESTROY
-    1:
+  GDK_DESTROY:
     begin
      // DebugLn('****** GDK_DESTROY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    // GDK_EXPOSE
-    2:
+  GDK_EXPOSE:
     begin
       // DebugLn('****** GDK_EXPOSE FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
       // Gtk3DrawWidget is attached to 'draw' signal, Expose event doesn't trigger
@@ -1024,86 +980,75 @@
        // we use 'draw' signal Gtk3DrawEvent()
       // Result := TGtk3Widget(Data).GtkEventPaint(Widget, Event);
     end;
-    // GDK_MOTION_NOTIFY
-    3:
+  GDK_MOTION_NOTIFY:
     begin
       // Result := TGtk3Widget(Data).GtkEventMouseMove(Widget, Event);
     end;
-    // GDK_BUTTON_PRESS:
-    4:
+  GDK_BUTTON_PRESS:
     begin
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_2BUTTON_PRESS:
-    5:
+  GDK_2BUTTON_PRESS:
     begin
       // if not TGtk3Widget(Data).LCLObject.Focused and TGtk3Widget(Data).LCLObject.CanFocus then
       //  LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_3BUTTON_PRESS:
-    6:
+  GDK_3BUTTON_PRESS:
     begin
       // if not TGtk3Widget(Data).LCLObject.Focused and TGtk3Widget(Data).LCLObject.CanFocus then
       //  LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_BUTTON_RELEASE:
-    7:
+  GDK_BUTTON_RELEASE:
     begin
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-
-    // GDK_KEY_PRESS
-    8:
+  GDK_KEY_PRESS:
     begin
       // if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
       //  Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, True);
     end;
-    // GDK_KEY_RELEASE
-    9:
+  GDK_KEY_RELEASE:
     begin
       // if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
       //  Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, False);
     end;
 
-    // GDK_ENTER_NOTIFY
-    10:
+  GDK_ENTER_NOTIFY:
     begin
       // TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    // GDK_LEAVE_NOTIFY
-    11:
+  GDK_LEAVE_NOTIFY:
     begin
       // TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    12:
+  GDK_FOCUS_CHANGE:
     begin
-      // GDK_FOCUS_CHANGE
+      //
     end;
-    // GDK_CONFIGURE
-    13:
+  GDK_CONFIGURE:
     begin
       // GDK_CONFIGURE
     end;
-    14: // GDK_MAP
+  GDK_MAP:
     begin
       // DebugLn('****** GDK_MAP FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    16: // GDK_PROPERTY_NOTIFY
+  GDK_PROPERTY_NOTIFY:
     begin
       // DebugLn('****** GDK_PROPERTY_NOTIFY FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    28: // GDK_CLIENT_EVENT
+  GDK_CLIENT_EVENT:
     begin
       // DebugLn('****** GDK_CLIENT_EVENT FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    29: // GDK_VISIBILITY_NOTIFY
+  GDK_VISIBILITY_NOTIFY:
     begin
       // Result := TGtk3Widget(Data).GtkEventShowHide(Widget, Event);
       // DebugLn('****** GDK_VISIBILITY_NOTIFY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    31: // GDK_SCROLL
+  GDK_SCROLL:
     begin
       // DebugLn('****** GDK_SCROLL ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
@@ -1143,8 +1088,7 @@
   if Assigned(Application) and Application.Terminated then
       exit;
   case event^.type_ of
-    // GDK_DELETE
-    0:
+  GDK_DELETE:
     begin
       // DebugLn('****** GDK_DELETE FOR ',dbgsName(TGtk3Widget(Data).LCLObject),' main_level=',dbgs(gtk_main_level));
       if wtWindow in TGtk3Widget(Data).WidgetType then
@@ -1154,13 +1098,11 @@
         Result := True;
       end;
     end;
-    // GDK_DESTROY
-    1:
+  GDK_DESTROY:
     begin
      // DebugLn('****** GDK_DESTROY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    // GDK_EXPOSE
-    2:
+  GDK_EXPOSE:
     begin
       DebugLn('****** GDK_EXPOSE FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
       // Gtk3DrawWidget is attached to 'draw' signal, Expose event doesn't trigger
@@ -1168,8 +1110,7 @@
        // we use 'draw' signal Gtk3DrawEvent()
       // Result := TGtk3Widget(Data).GtkEventPaint(Widget, Event);
     end;
-    // GDK_MOTION_NOTIFY
-    3:
+  GDK_MOTION_NOTIFY:
     begin
       if wtWindow in TGtk3Widget(Data).WidgetType then
       begin
@@ -1178,8 +1119,7 @@
       end;
       Result := TGtk3Widget(Data).GtkEventMouseMove(Widget, Event);
     end;
-    // GDK_BUTTON_PRESS:
-    4:
+  GDK_BUTTON_PRESS:
     begin
       // set focus before gtk does that, so we have same behaviour as other ws
       if TGtk3Widget(Data).GetFocusableByMouse and
@@ -1201,8 +1141,7 @@
 
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_2BUTTON_PRESS:
-    5:
+  GDK_2BUTTON_PRESS:
     begin
       // set focus before gtk does that, so we have same behaviour as other ws
       if TGtk3Widget(Data).GetFocusableByMouse and
@@ -1211,8 +1150,7 @@
           LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_3BUTTON_PRESS:
-    6:
+  GDK_3BUTTON_PRESS:
     begin
       // set focus before gtk does that, so we have same behaviour as other ws
       if TGtk3Widget(Data).GetFocusableByMouse and
@@ -1221,28 +1159,22 @@
           LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_BUTTON_RELEASE:
-    7:
+  GDK_BUTTON_RELEASE:
     begin
       if not (csClickEvents in TGtk3Widget(Data).LCLObject.ControlStyle) then
         Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-
-    // GDK_KEY_PRESS
-    8:
+  GDK_KEY_PRESS:
     begin
       if Widget^.has_focus then
         Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, True);
     end;
-    // GDK_KEY_RELEASE
-    9:
+  GDK_KEY_RELEASE:
     begin
       if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
         Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, False);
     end;
-
-    // GDK_ENTER_NOTIFY
-    10:
+  GDK_ENTER_NOTIFY:
     begin
       if wtWindow in TGtk3Widget(Data).WidgetType then
       begin
@@ -1268,8 +1200,7 @@
       *)
       TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    // GDK_LEAVE_NOTIFY
-    11:
+  GDK_LEAVE_NOTIFY:
     begin
       if wtWindow in TGtk3Widget(Data).WidgetType then
       begin
@@ -1297,8 +1228,7 @@
       *)
       TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    // GDK_FOCUS_CHANGE
-    12:
+  GDK_FOCUS_CHANGE:
     begin
       if wtComboBox in TGtk3Widget(Data).WidgetType then
       begin
@@ -1310,8 +1240,7 @@
       end;
       TGtk3Widget(Data).GtkEventFocus(Widget, Event);
     end;
-    // GDK_CONFIGURE
-    13:
+  GDK_CONFIGURE:
     begin
       (* DOES NOT WORK AS DOCUMENTATION SAYS
       if Data <> nil then
@@ -1326,23 +1255,23 @@
       *)
       Result := TGtk3Widget(Data).GtkEventResize(Widget, Event);
     end;
-    14: // GDK_MAP
+  GDK_MAP:
     begin
       // DebugLn('****** GDK_MAP FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    15: // GDK_UNMAP
+  GDK_UNMAP:
     begin
        // DebugLn('****** GDK_UNMAP FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    16: // GDK_PROPERTY_NOTIFY
+  GDK_PROPERTY_NOTIFY:
     begin
       // DebugLn('****** GDK_PROPERTY_NOTIFY FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    28: // GDK_CLIENT_EVENT
+  GDK_CLIENT_EVENT:
     begin
       // DebugLn('****** GDK_CLIENT_EVENT FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    29: // GDK_VISIBILITY_NOTIFY
+  GDK_VISIBILITY_NOTIFY:
     begin
       // ONLY HERE WE CAN CATCH Activate/Deactivate but problem is that
       // PGtkWindow does not update active property properly
@@ -1354,17 +1283,17 @@
       // Result := TGtk3Widget(Data).GtkEventShowHide(Widget, Event);
       // DebugLn('****** GDK_VISIBILITY_NOTIFY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    31: // GDK_SCROLL
+  GDK_SCROLL:
     begin
       // DebugLn('****** GDK_SCROLL ' + dbgsName(TGtk3Widget(Data).LCLObject));
       Result := TGtk3Widget(Data).GtkEventMouseWheel(Widget, Event);
     end;
-    32: // GDK_WINDOW_STATE
+  GDK_WINDOW_STATE:
     begin
       // DebugLn('****** GDK_WINDOW_STATE FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
       // this doesn't work as expected ... must use GDK_CONFIGURE to get active status ?!?
     end;
-    35: // GDK_GRAB_BROKEN  could be broken eg. because of popupmenu
+  GDK_GRAB_BROKEN:  //could be broken eg. because of popupmenu
     begin
       DebugLn('****** GDK_GRAB_BROKEN (no problem if popupmenu is activated) ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
@@ -2042,6 +1971,9 @@
   FillChar(Msg, SizeOf(Msg), 0);
   AEventString := AEvent.string_;
 
+  if AEventString='''' then
+    writeln('Trap');
+
   if gdk_keyval_is_lower(AEvent.keyval) then
     KeyValue := Word(gdk_keyval_to_upper(AEvent.keyval))
   else
@@ -2084,7 +2016,7 @@
     exit;
   end;
 
-  IsArrowKey := ((ACharCode = VK_UP) or (ACharCode = VK_DOWN) or (ACharCode = VK_LEFT) or (ACharCode = VK_RIGHT));
+  IsArrowKey := (AEventString='') and ((ACharCode = VK_UP) or (ACharCode = VK_DOWN) or (ACharCode = VK_LEFT) or (ACharCode = VK_RIGHT));
 
   {$IFDEF GTK3DEBUGKEYPRESS}
   if AKeyPress then
@@ -2110,11 +2042,14 @@
     if not CanSendLCLMessage then
       exit;
 
-    if (DeliverMessage(Msg, True) <> 0) or (Msg.CharCode = VK_UNKNOWN) or EatArrowKeys(ACharCode) then
+    if (DeliverMessage(Msg, True) <> 0) or (Msg.CharCode = VK_UNKNOWN) or (IsArrowKey{EatArrowKeys(ACharCode)}) then
     begin
       {$IFDEF GTK3DEBUGKEYPRESS}
       DebugLn('CN_KeyDownMsgs handled ... exiting');
       {$ENDIF}
+      if ([wtEntry,wtMemo] * WidgetType <>[]) then
+      exit(false)
+      else
       exit(True);
     end;
 
@@ -2135,7 +2070,7 @@
 
     {$warning workaround for GtkTreeView key bindings.Must find out what LCL does with
      this keys.}
-    if IsArrowKey and ([wtListBox,wtListView] * WidgetType <> []) then
+    if {IsArrowKey and} ([wtListBox,wtListView,wtEntry,wtMemo] * WidgetType <> []) then
     // let gtk3 select cell for now. Must check what LCL does with arrow keys
     // since gtk3 becomes crazy after delivery of this message
     else
@@ -2250,8 +2185,7 @@
   MButton := Event^.button.button;
 
   case Event^.type_ of
-    // GDK_BUTTON_PRESS
-    4:
+  GDK_BUTTON_PRESS:
     begin
       if MButton = GTK3_LEFT_BUTTON then
       begin
@@ -2271,8 +2205,7 @@
         Msg.Keys := Msg.Keys or MK_MBUTTON;
       end;
     end;
-    // GDK_BUTTON2_PRESS -> double click
-    5: // GDK_DOUBLE_BUTTON_PRESS
+  GDK_2BUTTON_PRESS: //-> double click GDK_DOUBLE_BUTTON_PRESS
     begin
       if MButton = GTK3_LEFT_BUTTON then
       begin
@@ -2292,8 +2225,7 @@
         Msg.Keys := Msg.Keys or MK_MBUTTON;
       end;
     end;
-    // GDK_BUTTON_RELEASE: TGdkEventType = 7;
-    7:
+  GDK_BUTTON_RELEASE:
     begin
       if MButton = GTK3_LEFT_BUTTON then
       begin
@@ -3625,6 +3557,7 @@
 var
   Msg: TLMessage;
 begin
+  exit;
   if AData <> nil then
   begin
     if TGtk3Widget(AData).InUpdate then
gtk3_key_mess.diff (20,721 bytes)   

Anton Kavalenka

2020-10-03 09:17

reporter   ~0126050

Sorry - 2nd patch without debugging remnants
gtk3_key_mess-2.diff (20,327 bytes)   
Index: lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas	(revision 63942)
+++ lcl/interfaces/gtk3/gtk3bindings/lazgdk3.pas	(working copy)
@@ -2625,53 +2625,53 @@
   GDK_GRAB_FROZEN: TGdkGrabStatus = 4;
 
 type
-  TGdkEventType = Integer;
-const
+  TGdkEventType = (
   { GdkEventType }
-  GDK_NOTHING: TGdkEventType = -1;
-  GDK_DELETE: TGdkEventType = 0;
-  GDK_DESTROY: TGdkEventType = 1;
-  GDK_EXPOSE: TGdkEventType = 2;
-  GDK_MOTION_NOTIFY: TGdkEventType = 3;
-  GDK_BUTTON_PRESS: TGdkEventType = 4;
-  GDK_2BUTTON_PRESS: TGdkEventType = 5;
-  GDK_DOUBLE_BUTTON_PRESS: TGdkEventType = 5;
-  GDK_3BUTTON_PRESS: TGdkEventType = 6;
-  GDK_TRIPLE_BUTTON_PRESS: TGdkEventType = 6;
-  GDK_BUTTON_RELEASE: TGdkEventType = 7;
-  GDK_KEY_PRESS: TGdkEventType = 8;
-  GDK_KEY_RELEASE: TGdkEventType = 9;
-  GDK_ENTER_NOTIFY: TGdkEventType = 10;
-  GDK_LEAVE_NOTIFY: TGdkEventType = 11;
-  GDK_FOCUS_CHANGE: TGdkEventType = 12;
-  GDK_CONFIGURE: TGdkEventType = 13;
-  GDK_MAP: TGdkEventType = 14;
-  GDK_UNMAP: TGdkEventType = 15;
-  GDK_PROPERTY_NOTIFY: TGdkEventType = 16;
-  GDK_SELECTION_CLEAR: TGdkEventType = 17;
-  GDK_SELECTION_REQUEST: TGdkEventType = 18;
-  GDK_SELECTION_NOTIFY: TGdkEventType = 19;
-  GDK_PROXIMITY_IN: TGdkEventType = 20;
-  GDK_PROXIMITY_OUT: TGdkEventType = 21;
-  GDK_DRAG_ENTER: TGdkEventType = 22;
-  GDK_DRAG_LEAVE: TGdkEventType = 23;
-  GDK_DRAG_MOTION_: TGdkEventType = 24;
-  GDK_DRAG_STATUS_: TGdkEventType = 25;
-  GDK_DROP_START: TGdkEventType = 26;
-  GDK_DROP_FINISHED: TGdkEventType = 27;
-  GDK_CLIENT_EVENT: TGdkEventType = 28;
-  GDK_VISIBILITY_NOTIFY: TGdkEventType = 29;
-  GDK_SCROLL: TGdkEventType = 31;
-  GDK_WINDOW_STATE: TGdkEventType = 32;
-  GDK_SETTING: TGdkEventType = 33;
-  GDK_OWNER_CHANGE: TGdkEventType = 34;
-  GDK_GRAB_BROKEN: TGdkEventType = 35;
-  GDK_DAMAGE: TGdkEventType = 36;
-  GDK_TOUCH_BEGIN: TGdkEventType = 37;
-  GDK_TOUCH_UPDATE: TGdkEventType = 38;
-  GDK_TOUCH_END: TGdkEventType = 39;
-  GDK_TOUCH_CANCEL: TGdkEventType = 40;
-  GDK_EVENT_LAST: TGdkEventType = 41;
+  GDK_NOTHING = -1,
+  GDK_DELETE = 0,
+  GDK_DESTROY = 1,
+  GDK_EXPOSE = 2,
+  GDK_MOTION_NOTIFY = 3,
+  GDK_BUTTON_PRESS = 4,
+  GDK_2BUTTON_PRESS = 5,
+  GDK_DOUBLE_BUTTON_PRESS = 5,
+  GDK_3BUTTON_PRESS = 6,
+  GDK_TRIPLE_BUTTON_PRESS = 6,
+  GDK_BUTTON_RELEASE = 7,
+  GDK_KEY_PRESS = 8,
+  GDK_KEY_RELEASE = 9,
+  GDK_ENTER_NOTIFY = 10,
+  GDK_LEAVE_NOTIFY = 11,
+  GDK_FOCUS_CHANGE = 12,
+  GDK_CONFIGURE = 13,
+  GDK_MAP = 14,
+  GDK_UNMAP = 15,
+  GDK_PROPERTY_NOTIFY = 16,
+  GDK_SELECTION_CLEAR = 17,
+  GDK_SELECTION_REQUEST = 18,
+  GDK_SELECTION_NOTIFY = 19,
+  GDK_PROXIMITY_IN = 20,
+  GDK_PROXIMITY_OUT = 21,
+  GDK_DRAG_ENTER = 22,
+  GDK_DRAG_LEAVE = 23,
+  GDK_DRAG_MOTION_ = 24,
+  GDK_DRAG_STATUS_ = 25,
+  GDK_DROP_START = 26,
+  GDK_DROP_FINISHED = 27,
+  GDK_CLIENT_EVENT = 28,
+  GDK_VISIBILITY_NOTIFY = 29,
+  GDK_SCROLL = 31,
+  GDK_WINDOW_STATE = 32,
+  GDK_SETTING = 33,
+  GDK_OWNER_CHANGE = 34,
+  GDK_GRAB_BROKEN = 35,
+  GDK_DAMAGE = 36,
+  GDK_TOUCH_BEGIN = 37,
+  GDK_TOUCH_UPDATE = 38,
+  GDK_TOUCH_END = 39,
+  GDK_TOUCH_CANCEL = 40,
+  GDK_EVENT_LAST = 41
+  );
 
 type
   TGdkVisibilityState = Integer;
Index: lcl/interfaces/gtk3/gtk3procs.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3procs.pas	(revision 63942)
+++ lcl/interfaces/gtk3/gtk3procs.pas	(working copy)
@@ -647,10 +647,10 @@
     GDK_KEY_End: Result := VK_END;
     GDK_KEY_Page_Up: Result := VK_PRIOR;
     GDK_KEY_Page_Down: Result := VK_NEXT;
-    GDK_KEY_Left: Result := VK_LEFT;
-    GDK_KEY_Up: Result := VK_UP;
-    GDK_KEY_Right: Result := VK_RIGHT;
-    GDK_KEY_Down: Result := VK_DOWN;
+    GDK_KEY_Left, GDK_KEY_KP_LEFT: Result := VK_LEFT;
+    GDK_KEY_Up, GDK_KEY_KP_UP: Result := VK_UP;
+    GDK_KEY_Right, GDK_KEY_KP_Right: Result := VK_RIGHT;
+    GDK_KEY_Down, GDK_KEY_KP_Down: Result := VK_DOWN;
     GDK_KEY_Menu: Result := VK_APPS;
     GDK_KEY_Tab, GDK_KEY_3270_BackTab, GDK_KEY_ISO_Left_Tab: Result := VK_TAB;
     GDK_KEY_Shift_L, GDK_KEY_Shift_R: Result := VK_SHIFT;
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 63942)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -909,88 +909,47 @@
 begin
   Result := 'GDK_NOTHING';
   case AEvent of
-    // GDK_DELETE:
-    0: Result := 'GDK_DELETE';
-    // GDK_DESTROY:
-    1: Result := 'GDK_DESTROY';
-    // GDK_EXPOSE:
-    2: Result := 'GDK_EXPOSE';
-    // GDK_MOTION_NOTIFY:
-    3: Result := 'GDK_MOTION_NOTIFY';
-    // GDK_BUTTON_PRESS:
-    4: Result := 'GDK_BUTTON_PRESS';
-    // GDK_2BUTTON_PRESS:
-    5: Result := 'GDK_2BUTTON_PRESS';
-    // GDK_3BUTTON_PRESS:
-    6: Result := 'GDK_3BUTTON_PRESS';
-    // GDK_BUTTON_RELEASE:
-    7: Result := 'GDK_BUTTON_RELEASE';
-    // GDK_KEY_PRESS:
-    8: Result := 'GDK_KEY_PRESS';
-    // GDK_KEY_RELEASE:
-    9: Result := 'GDK_KEY_RELEASE';
-    // GDK_ENTER_NOTIFY:
-    10: Result := 'GDK_ENTER_NOTIFY';
-    // GDK_LEAVE_NOTIFY:
-    11: Result := 'GDK_LEAVE_NOTIFY';
-    // GDK_FOCUS_CHANGE:
-    12: Result := 'GDK_FOCUS_CHANGE';
-    // GDK_CONFIGURE:
-    13: Result := 'GDK_CONFIGURE';
-    // GDK_MAP:
-    14: Result := 'GDK_MAP';
-    // GDK_UNMAP:
-    15: Result := 'GDK_UNMAP';
-    // GDK_PROPERTY_NOTIFY:
-    16: Result := 'GDK_PROPERTY_NOTIFY';
-    // GDK_SELECTION_CLEAR:
-    17: Result := 'GDK_SELECTION_CLEAR';
-    // GDK_SELECTION_REQUEST:
-    18: Result := 'GDK_SELECTION_REQUEST';
-    // GDK_SELECTION_NOTIFY:
-    19: Result := 'GDK_SELECTION_NOTIFY';
-    // GDK_PROXIMITY_IN:
-    20: Result := 'GDK_PROXIMITY_IN';
-    // GDK_PROXIMITY_OUT:
-    21: Result := 'GDK_PROXIMITY_OUT';
-    // GDK_DRAG_ENTER:
-    22: Result := 'GDK_DRAG_ENTER';
-    // GDK_DRAG_LEAVE:
-    23: Result := 'GDK_DRAG_LEAVE';
-    // GDK_DRAG_MOTION_:
-    24: Result := 'GDK_DRAG_MOTION_';
-    // GDK_DRAG_STATUS_:
-    25: Result := 'GDK_DRAG_STATUS_';
-    // GDK_DROP_START:
-    26: Result := 'GDK_DROP_START';
-    // GDK_DROP_FINISHED:
-    27: Result := 'GDK_DROP_FINISHED';
-    // GDK_CLIENT_EVENT:
-    28: Result := 'GDK_CLIENT_EVENT';
-    // GDK_VISIBILITY_NOTIFY:
-    29: Result := 'GDK_VISIBILITY_NOTIFY';
-    // GDK_SCROLL:
-    31: Result := 'GDK_SCROLL';
-    // GDK_WINDOW_STATE:
-    32: Result := 'GDK_WINDOW_STATE';
-    // GDK_SETTING:
-    33: Result := 'GDK_SETTING';
-    // GDK_OWNER_CHANGE:
-    34: Result := 'GDK_OWNER_CHANGE';
-    // GDK_GRAB_BROKEN:
-    35: Result := 'GDK_GRAB_BROKEN';
-    // GDK_DAMAGE:
-    36: Result := 'GDK_DAMAGE';
-    // GDK_TOUCH_BEGIN:
-    37: Result := 'GDK_TOUCH_BEGIN';
-    // GDK_TOUCH_UPDATE:
-    38: Result := 'GDK_TOUCH_UPDATE';
-    // GDK_TOUCH_END:
-    39: Result := 'GDK_TOUCH_END';
-    // GDK_TOUCH_CANCEL:
-    40: Result := 'GDK_TOUCH_CANCEL';
-    // GDK_EVENT_LAST:
-    41: Result := 'GDK_EVENT_LAST';
+  GDK_DELETE: Result := 'GDK_DELETE';
+  GDK_DESTROY: Result := 'GDK_DESTROY';
+  GDK_EXPOSE: Result := 'GDK_EXPOSE';
+  GDK_MOTION_NOTIFY: Result := 'GDK_MOTION_NOTIFY';
+  GDK_BUTTON_PRESS: Result := 'GDK_BUTTON_PRESS';
+  GDK_2BUTTON_PRESS: Result := 'GDK_2BUTTON_PRESS';
+  GDK_3BUTTON_PRESS: Result := 'GDK_3BUTTON_PRESS';
+  GDK_BUTTON_RELEASE: Result := 'GDK_BUTTON_RELEASE';
+  GDK_KEY_PRESS: Result := 'GDK_KEY_PRESS';
+  GDK_KEY_RELEASE: Result := 'GDK_KEY_RELEASE';
+  GDK_ENTER_NOTIFY: Result := 'GDK_ENTER_NOTIFY';
+  GDK_LEAVE_NOTIFY: Result := 'GDK_LEAVE_NOTIFY';
+  GDK_FOCUS_CHANGE: Result := 'GDK_FOCUS_CHANGE';
+  GDK_CONFIGURE: Result := 'GDK_CONFIGURE';
+  GDK_MAP: Result := 'GDK_MAP';
+  GDK_UNMAP: Result := 'GDK_UNMAP';
+  GDK_PROPERTY_NOTIFY: Result := 'GDK_PROPERTY_NOTIFY';
+  GDK_SELECTION_CLEAR: Result := 'GDK_SELECTION_CLEAR';
+  GDK_SELECTION_REQUEST: Result := 'GDK_SELECTION_REQUEST';
+  GDK_SELECTION_NOTIFY: Result := 'GDK_SELECTION_NOTIFY';
+  GDK_PROXIMITY_IN: Result := 'GDK_PROXIMITY_IN';
+  GDK_PROXIMITY_OUT: Result := 'GDK_PROXIMITY_OUT';
+  GDK_DRAG_ENTER: Result := 'GDK_DRAG_ENTER';
+  GDK_DRAG_LEAVE: Result := 'GDK_DRAG_LEAVE';
+  GDK_DRAG_MOTION_: Result := 'GDK_DRAG_MOTION_';
+  GDK_DRAG_STATUS_: Result := 'GDK_DRAG_STATUS_';
+  GDK_DROP_START: Result := 'GDK_DROP_START';
+  GDK_DROP_FINISHED: Result := 'GDK_DROP_FINISHED';
+  GDK_CLIENT_EVENT: Result := 'GDK_CLIENT_EVENT';
+  GDK_VISIBILITY_NOTIFY: Result := 'GDK_VISIBILITY_NOTIFY';
+  GDK_SCROLL: Result := 'GDK_SCROLL';
+  GDK_WINDOW_STATE: Result := 'GDK_WINDOW_STATE';
+  GDK_SETTING: Result := 'GDK_SETTING';
+  GDK_OWNER_CHANGE: Result := 'GDK_OWNER_CHANGE';
+  GDK_GRAB_BROKEN: Result := 'GDK_GRAB_BROKEN';
+  GDK_DAMAGE: Result := 'GDK_DAMAGE';
+  GDK_TOUCH_BEGIN: Result := 'GDK_TOUCH_BEGIN';
+  GDK_TOUCH_UPDATE: Result := 'GDK_TOUCH_UPDATE';
+  GDK_TOUCH_END: Result := 'GDK_TOUCH_END';
+  GDK_TOUCH_CANCEL: Result := 'GDK_TOUCH_CANCEL';
+  GDK_EVENT_LAST: Result := 'GDK_EVENT_LAST';
   end;
 end;
 
@@ -1005,18 +964,15 @@
   //  ' ',Gtk3EventToStr(event^.type_));
 
   case event^.type_ of
-    // GDK_DELETE
-    0:
+  GDK_DELETE:
     begin
       // DebugLn('****** GDK_DELETE FOR ',dbgsName(TGtk3Widget(Data).LCLObject),' main_level=',dbgs(gtk_main_level));
     end;
-    // GDK_DESTROY
-    1:
+  GDK_DESTROY:
     begin
      // DebugLn('****** GDK_DESTROY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    // GDK_EXPOSE
-    2:
+  GDK_EXPOSE:
     begin
       // DebugLn('****** GDK_EXPOSE FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
       // Gtk3DrawWidget is attached to 'draw' signal, Expose event doesn't trigger
@@ -1024,86 +980,75 @@
        // we use 'draw' signal Gtk3DrawEvent()
       // Result := TGtk3Widget(Data).GtkEventPaint(Widget, Event);
     end;
-    // GDK_MOTION_NOTIFY
-    3:
+  GDK_MOTION_NOTIFY:
     begin
       // Result := TGtk3Widget(Data).GtkEventMouseMove(Widget, Event);
     end;
-    // GDK_BUTTON_PRESS:
-    4:
+  GDK_BUTTON_PRESS:
     begin
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_2BUTTON_PRESS:
-    5:
+  GDK_2BUTTON_PRESS:
     begin
       // if not TGtk3Widget(Data).LCLObject.Focused and TGtk3Widget(Data).LCLObject.CanFocus then
       //  LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_3BUTTON_PRESS:
-    6:
+  GDK_3BUTTON_PRESS:
     begin
       // if not TGtk3Widget(Data).LCLObject.Focused and TGtk3Widget(Data).LCLObject.CanFocus then
       //  LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_BUTTON_RELEASE:
-    7:
+  GDK_BUTTON_RELEASE:
     begin
       // Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-
-    // GDK_KEY_PRESS
-    8:
+  GDK_KEY_PRESS:
     begin
       // if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
       //  Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, True);
     end;
-    // GDK_KEY_RELEASE
-    9:
+  GDK_KEY_RELEASE:
     begin
       // if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
       //  Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, False);
     end;
 
-    // GDK_ENTER_NOTIFY
-    10:
+  GDK_ENTER_NOTIFY:
     begin
       // TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    // GDK_LEAVE_NOTIFY
-    11:
+  GDK_LEAVE_NOTIFY:
     begin
       // TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    12:
+  GDK_FOCUS_CHANGE:
     begin
-      // GDK_FOCUS_CHANGE
+      //
     end;
-    // GDK_CONFIGURE
-    13:
+  GDK_CONFIGURE:
     begin
       // GDK_CONFIGURE
     end;
-    14: // GDK_MAP
+  GDK_MAP:
     begin
       // DebugLn('****** GDK_MAP FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    16: // GDK_PROPERTY_NOTIFY
+  GDK_PROPERTY_NOTIFY:
     begin
       // DebugLn('****** GDK_PROPERTY_NOTIFY FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    28: // GDK_CLIENT_EVENT
+  GDK_CLIENT_EVENT:
     begin
       // DebugLn('****** GDK_CLIENT_EVENT FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    29: // GDK_VISIBILITY_NOTIFY
+  GDK_VISIBILITY_NOTIFY:
     begin
       // Result := TGtk3Widget(Data).GtkEventShowHide(Widget, Event);
       // DebugLn('****** GDK_VISIBILITY_NOTIFY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    31: // GDK_SCROLL
+  GDK_SCROLL:
     begin
       // DebugLn('****** GDK_SCROLL ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
@@ -1143,8 +1088,7 @@
   if Assigned(Application) and Application.Terminated then
       exit;
   case event^.type_ of
-    // GDK_DELETE
-    0:
+  GDK_DELETE:
     begin
       // DebugLn('****** GDK_DELETE FOR ',dbgsName(TGtk3Widget(Data).LCLObject),' main_level=',dbgs(gtk_main_level));
       if wtWindow in TGtk3Widget(Data).WidgetType then
@@ -1154,13 +1098,11 @@
         Result := True;
       end;
     end;
-    // GDK_DESTROY
-    1:
+  GDK_DESTROY:
     begin
      // DebugLn('****** GDK_DESTROY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    // GDK_EXPOSE
-    2:
+  GDK_EXPOSE:
     begin
       DebugLn('****** GDK_EXPOSE FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
       // Gtk3DrawWidget is attached to 'draw' signal, Expose event doesn't trigger
@@ -1168,8 +1110,7 @@
        // we use 'draw' signal Gtk3DrawEvent()
       // Result := TGtk3Widget(Data).GtkEventPaint(Widget, Event);
     end;
-    // GDK_MOTION_NOTIFY
-    3:
+  GDK_MOTION_NOTIFY:
     begin
       if wtWindow in TGtk3Widget(Data).WidgetType then
       begin
@@ -1178,8 +1119,7 @@
       end;
       Result := TGtk3Widget(Data).GtkEventMouseMove(Widget, Event);
     end;
-    // GDK_BUTTON_PRESS:
-    4:
+  GDK_BUTTON_PRESS:
     begin
       // set focus before gtk does that, so we have same behaviour as other ws
       if TGtk3Widget(Data).GetFocusableByMouse and
@@ -1201,8 +1141,7 @@
 
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_2BUTTON_PRESS:
-    5:
+  GDK_2BUTTON_PRESS:
     begin
       // set focus before gtk does that, so we have same behaviour as other ws
       if TGtk3Widget(Data).GetFocusableByMouse and
@@ -1211,8 +1150,7 @@
           LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_3BUTTON_PRESS:
-    6:
+  GDK_3BUTTON_PRESS:
     begin
       // set focus before gtk does that, so we have same behaviour as other ws
       if TGtk3Widget(Data).GetFocusableByMouse and
@@ -1221,28 +1159,22 @@
           LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-    // GDK_BUTTON_RELEASE:
-    7:
+  GDK_BUTTON_RELEASE:
     begin
       if not (csClickEvents in TGtk3Widget(Data).LCLObject.ControlStyle) then
         Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
-
-    // GDK_KEY_PRESS
-    8:
+  GDK_KEY_PRESS:
     begin
       if Widget^.has_focus then
         Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, True);
     end;
-    // GDK_KEY_RELEASE
-    9:
+  GDK_KEY_RELEASE:
     begin
       if Widget^.has_focus then // or (Widget = TGtk3Widget(data).GetContainerWidget) then
         Result := TGtk3Widget(Data).GtkEventKey(Widget, Event, False);
     end;
-
-    // GDK_ENTER_NOTIFY
-    10:
+  GDK_ENTER_NOTIFY:
     begin
       if wtWindow in TGtk3Widget(Data).WidgetType then
       begin
@@ -1268,8 +1200,7 @@
       *)
       TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    // GDK_LEAVE_NOTIFY
-    11:
+  GDK_LEAVE_NOTIFY:
     begin
       if wtWindow in TGtk3Widget(Data).WidgetType then
       begin
@@ -1297,8 +1228,7 @@
       *)
       TGtk3Widget(Data).GtkEventMouseEnterLeave(Widget, Event);
     end;
-    // GDK_FOCUS_CHANGE
-    12:
+  GDK_FOCUS_CHANGE:
     begin
       if wtComboBox in TGtk3Widget(Data).WidgetType then
       begin
@@ -1310,8 +1240,7 @@
       end;
       TGtk3Widget(Data).GtkEventFocus(Widget, Event);
     end;
-    // GDK_CONFIGURE
-    13:
+  GDK_CONFIGURE:
     begin
       (* DOES NOT WORK AS DOCUMENTATION SAYS
       if Data <> nil then
@@ -1326,23 +1255,23 @@
       *)
       Result := TGtk3Widget(Data).GtkEventResize(Widget, Event);
     end;
-    14: // GDK_MAP
+  GDK_MAP:
     begin
       // DebugLn('****** GDK_MAP FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    15: // GDK_UNMAP
+  GDK_UNMAP:
     begin
        // DebugLn('****** GDK_UNMAP FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    16: // GDK_PROPERTY_NOTIFY
+  GDK_PROPERTY_NOTIFY:
     begin
       // DebugLn('****** GDK_PROPERTY_NOTIFY FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    28: // GDK_CLIENT_EVENT
+  GDK_CLIENT_EVENT:
     begin
       // DebugLn('****** GDK_CLIENT_EVENT FOR ',dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    29: // GDK_VISIBILITY_NOTIFY
+  GDK_VISIBILITY_NOTIFY:
     begin
       // ONLY HERE WE CAN CATCH Activate/Deactivate but problem is that
       // PGtkWindow does not update active property properly
@@ -1354,17 +1283,17 @@
       // Result := TGtk3Widget(Data).GtkEventShowHide(Widget, Event);
       // DebugLn('****** GDK_VISIBILITY_NOTIFY FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
-    31: // GDK_SCROLL
+  GDK_SCROLL:
     begin
       // DebugLn('****** GDK_SCROLL ' + dbgsName(TGtk3Widget(Data).LCLObject));
       Result := TGtk3Widget(Data).GtkEventMouseWheel(Widget, Event);
     end;
-    32: // GDK_WINDOW_STATE
+  GDK_WINDOW_STATE:
     begin
       // DebugLn('****** GDK_WINDOW_STATE FOR ' + dbgsName(TGtk3Widget(Data).LCLObject));
       // this doesn't work as expected ... must use GDK_CONFIGURE to get active status ?!?
     end;
-    35: // GDK_GRAB_BROKEN  could be broken eg. because of popupmenu
+  GDK_GRAB_BROKEN:  //could be broken eg. because of popupmenu
     begin
       DebugLn('****** GDK_GRAB_BROKEN (no problem if popupmenu is activated) ' + dbgsName(TGtk3Widget(Data).LCLObject));
     end;
@@ -2084,7 +2013,7 @@
     exit;
   end;
 
-  IsArrowKey := ((ACharCode = VK_UP) or (ACharCode = VK_DOWN) or (ACharCode = VK_LEFT) or (ACharCode = VK_RIGHT));
+  IsArrowKey := (AEventString='') and ((ACharCode = VK_UP) or (ACharCode = VK_DOWN) or (ACharCode = VK_LEFT) or (ACharCode = VK_RIGHT));
 
   {$IFDEF GTK3DEBUGKEYPRESS}
   if AKeyPress then
@@ -2110,11 +2039,14 @@
     if not CanSendLCLMessage then
       exit;
 
-    if (DeliverMessage(Msg, True) <> 0) or (Msg.CharCode = VK_UNKNOWN) or EatArrowKeys(ACharCode) then
+    if (DeliverMessage(Msg, True) <> 0) or (Msg.CharCode = VK_UNKNOWN) or (IsArrowKey{EatArrowKeys(ACharCode)}) then
     begin
       {$IFDEF GTK3DEBUGKEYPRESS}
       DebugLn('CN_KeyDownMsgs handled ... exiting');
       {$ENDIF}
+      if ([wtEntry,wtMemo] * WidgetType <>[]) then
+      exit(false)
+      else
       exit(True);
     end;
 
@@ -2135,7 +2067,7 @@
 
     {$warning workaround for GtkTreeView key bindings.Must find out what LCL does with
      this keys.}
-    if IsArrowKey and ([wtListBox,wtListView] * WidgetType <> []) then
+    if {IsArrowKey and} ([wtListBox,wtListView,wtEntry,wtMemo] * WidgetType <> []) then
     // let gtk3 select cell for now. Must check what LCL does with arrow keys
     // since gtk3 becomes crazy after delivery of this message
     else
@@ -2250,8 +2182,7 @@
   MButton := Event^.button.button;
 
   case Event^.type_ of
-    // GDK_BUTTON_PRESS
-    4:
+  GDK_BUTTON_PRESS:
     begin
       if MButton = GTK3_LEFT_BUTTON then
       begin
@@ -2271,8 +2202,7 @@
         Msg.Keys := Msg.Keys or MK_MBUTTON;
       end;
     end;
-    // GDK_BUTTON2_PRESS -> double click
-    5: // GDK_DOUBLE_BUTTON_PRESS
+  GDK_2BUTTON_PRESS: //-> double click GDK_DOUBLE_BUTTON_PRESS
     begin
       if MButton = GTK3_LEFT_BUTTON then
       begin
@@ -2292,8 +2222,7 @@
         Msg.Keys := Msg.Keys or MK_MBUTTON;
       end;
     end;
-    // GDK_BUTTON_RELEASE: TGdkEventType = 7;
-    7:
+  GDK_BUTTON_RELEASE:
     begin
       if MButton = GTK3_LEFT_BUTTON then
       begin
gtk3_key_mess-2.diff (20,327 bytes)   

CudaText man

2020-10-03 10:57

reporter   ~0126052

Thanks again, Anton.

Juha Manninen

2020-10-03 11:31

developer   ~0126055

Applied, thanks.

Issue History

Date Modified Username Field Change
2020-09-27 19:28 CudaText man_ New Issue
2020-09-27 21:20 Anton Kavalenka Note Added: 0125909
2020-09-27 22:13 jamie philbrook Note Added: 0125910
2020-09-27 22:13 jamie philbrook Note Edited: 0125910 View Revisions
2020-10-03 09:14 Anton Kavalenka Note Added: 0126048
2020-10-03 09:14 Anton Kavalenka File Added: gtk3_key_mess.diff
2020-10-03 09:17 Anton Kavalenka Note Added: 0126050
2020-10-03 09:17 Anton Kavalenka File Added: gtk3_key_mess-2.diff
2020-10-03 10:27 Juha Manninen Assigned To => Juha Manninen
2020-10-03 10:27 Juha Manninen Status new => assigned
2020-10-03 10:57 CudaText man Note Added: 0126052
2020-10-03 11:31 Juha Manninen Status assigned => resolved
2020-10-03 11:31 Juha Manninen Resolution open => fixed
2020-10-03 11:31 Juha Manninen Fixed in Revision => r63948
2020-10-03 11:31 Juha Manninen LazTarget => -
2020-10-03 11:31 Juha Manninen Widgetset GTK 3 => GTK 3
2020-10-03 11:31 Juha Manninen Note Added: 0126055
2020-10-05 13:40 CudaText man_ Status resolved => closed