View Issue Details

IDProjectCategoryView StatusLast Update
0038941LazarusWidgetsetpublic2021-06-10 20:30
ReporterChris Rorden Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformRyzen 3900xOSUbuntu 
Product Version2.0.13 (SVN) 
Summary0038941: GTK3: TPanel never fires MouseUp event
DescriptionGTK3 widgetset does not generate mouseup events.
Steps To ReproduceCreate a new project. Set widgetset to GTK3. Add TPanel. Set TPanel to generate MouseUp event. Run program to demonstrate this event is never generated.

procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Caption := 'Up'; //Never fired in GTK3
end;
TagsNo tags attached.
Fixed in Revisionr65191
LazTarget-
WidgetsetGTK 3
Attached Files

Relationships

related to 0038942 resolvedJuha Manninen gtk3: Make Listview display icons in vsIcon mode 

Activities

Anton Kavalenka

2021-05-28 16:40

reporter   ~0131074

Got it.
It is a mess introduced with appearing of native buttons "click" handlers.
Fighting with multiple OnClick lead to break in Mousecapture handling.

Ugly workaround with test app (which were too-lame-to-be-written by scientists :))))
gtk3mouseup.diff (4,842 bytes)   
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 65143)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -1131,6 +1131,7 @@
     end;
   GDK_BUTTON_PRESS:
     begin
+      writeln('Press:',TGtk3Widget(Data).LCLObject.ClassName);
       // set focus before gtk does that, so we have same behaviour as other ws
       if TGtk3Widget(Data).GetFocusableByMouse and
         not TGtk3Widget(Data).LCLObject.Focused and
@@ -1149,7 +1150,11 @@
           LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
       end;
 
-      Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
+      if TGtk3Widget(Data).LCLObject is TButtonControl then exit;
+
+
+      TGtk3Widget(Data).GtkEventMouse(Widget , Event);
+      Result:=true;
     end;
   GDK_2BUTTON_PRESS:
     begin
@@ -1158,6 +1163,8 @@
         not TGtk3Widget(Data).LCLObject.Focused and
         TGtk3Widget(Data).LCLObject.CanFocus then
           LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
+
+      if TGtk3Widget(Data).LCLObject is TButtonControl then exit;
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
   GDK_3BUTTON_PRESS:
@@ -1167,13 +1174,21 @@
         not TGtk3Widget(Data).LCLObject.Focused and
         TGtk3Widget(Data).LCLObject.CanFocus then
           LCLIntf.SetFocus(HWND(TGtk3Widget(Data)));
+
+      if TGtk3Widget(Data).LCLObject is TButtonControl then exit;
+
+
       Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
   GDK_BUTTON_RELEASE:
     begin
-      if not ((csClickEvents in TGtk3Widget(Data).LCLObject.ControlStyle) and
-         (csClicked in TGtk3Widget(Data).LCLObject.ControlState)) then
-        Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
+      writeln('Release:',TGtk3Widget(Data).LCLObject.ClassName);
+      {if not ((csClickEvents in TGtk3Widget(Data).LCLObject.ControlStyle) and
+         (csClicked in TGtk3Widget(Data).LCLObject.ControlState)) then }
+
+      if TGtk3Widget(Data).LCLObject is TButtonControl then exit;
+
+      Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
   GDK_KEY_PRESS:
     begin
@@ -2579,7 +2594,11 @@
 procedure TGtk3Widget.DestroyWidget;
 begin
   if IsValidHandle and FOwnWidget then
+  begin
+    DbgOut(#10'destroying '+Classname+' ... ');
     FWidget^.destroy_;
+    DbgOut(Classname+' destroyed.'+#10);
+  end;
   FWidget := nil;
 end;
 
@@ -5799,6 +5818,9 @@
   AScrollStyle: TPoint;
   PtrType: GType;
   TreeModel: PGtkTreeModel;
+  iter:TGtkTreeIter;
+  pxb:PGdkPixbuf;
+  err:gint;
 begin
   FImages := nil;
   FScrollX := 0;
@@ -5810,12 +5832,24 @@
 
   PtrType := G_TYPE_POINTER;
 
-  TreeModel := PGtkTreeModel(gtk_list_store_newv(1, @PtrType));
 
+
   if TListView(AListView).ViewStyle in [vsIcon,vsSmallIcon] then
-    FCentralWidget := TGtkIconView.new_with_model(TreeModel)
+  begin
+    TreeModel := PGtkTreeModel(gtk_list_store_new(3, [
+      G_TYPE_POINTER, // ListItem pointer
+      G_TYPE_STRING, // text
+     gdk_pixbuf_get_type() // pixbuf
+     ]));
+    FCentralWidget := TGtkIconView.new_with_model(TreeModel);
+    PGtkIconView(FCentralWidget)^.set_text_column(1);
+    PGtkIconView(FCentralWidget)^.set_pixbuf_column(2);
+  end
   else
+  begin
+    TreeModel := PGtkTreeModel(gtk_list_store_newv(1, @PtrType));
     FCentralWidget := TGtkTreeView.new_with_model(TreeModel);
+  end;
 
   FIsTreeView := not (TListView(AListView).ViewStyle in [vsIcon,vsSmallIcon]);
 
@@ -6195,6 +6229,8 @@
   AModel: PGtkTreeModel;
   Iter: TGtkTreeIter;
   NewIndex: Integer;
+  bmp:TBitmap;
+  pxb:PGdkPixbuf;
 begin
   if not IsWidgetOK then
     exit;
@@ -6207,10 +6243,22 @@
     NewIndex := AModel^.iter_n_children(nil)
   else
     NewIndex := AIndex;
-  // AGValue.g_type := G_TYPE_POINTER;
-  // AGValue.set_pointer(AItem);
-  gtk_list_store_insert_with_values(PGtkListStore(AModel), @Iter, NewIndex, [0, Pointer(AItem), -1]);
-  // PGtkListStore(AModel)^.insert_with_valuesv(@Iter, NewIndex, @AColumns, @AGValue, 1);
+
+  if IsTreeView then
+    gtk_list_store_insert_with_values(PGtkListStore(AModel), @Iter, NewIndex,
+      [0, Pointer(AItem), -1])
+  else
+  begin
+    bmp:=TBitmap.Create;
+    TListView(LCLObject).LargeImages.GetBitmap(AIndex,bmp);
+    pxb:=TGtk3Image(bmp.Handle).Handle;
+    gtk_list_store_insert_with_values(PGtkListStore(AModel), @Iter, NewIndex,
+      [0, Pointer(AItem),
+       1, PChar(AItem.Caption),
+       2, pxb, -1] );
+    fImages.Add(bmp);
+  end;
+
 end;
 
 procedure TGtk3ListView.ItemSetText(AIndex, ASubIndex: Integer;
@@ -6221,8 +6269,7 @@
 begin
   if not IsWidgetOK then
     exit;
-  if not getContainerWidget^.get_realized then
-    exit;
+
   if IsTreeView then
   begin
     Path := gtk_tree_path_new_from_indices(AIndex, [-1]);
gtk3mouseup.diff (4,842 bytes)   
project1.zip (108,562 bytes)

Anton Kavalenka

2021-05-28 16:42

reporter   ~0131075

including patch for 0038942

Juha Manninen

2021-05-30 17:48

developer   ~0131094

I will test and apply it after few days. I must be away from my development machine for some time.

Juha Manninen

2021-06-10 20:29

developer   ~0131230

i am back! Applied, thanks.

Issue History

Date Modified Username Field Change
2021-05-28 12:38 Chris Rorden New Issue
2021-05-28 13:44 Bart Broersma Category LCL => Widgetset
2021-05-28 13:44 Bart Broersma LazTarget => -
2021-05-28 13:44 Bart Broersma Widgetset GTK 3 => GTK 3
2021-05-28 16:40 Anton Kavalenka Note Added: 0131074
2021-05-28 16:40 Anton Kavalenka File Added: gtk3mouseup.diff
2021-05-28 16:40 Anton Kavalenka File Added: project1.zip
2021-05-28 16:42 Anton Kavalenka Note Added: 0131075
2021-05-29 07:56 Juha Manninen Assigned To => Juha Manninen
2021-05-29 07:56 Juha Manninen Status new => assigned
2021-05-30 17:48 Juha Manninen Note Added: 0131094
2021-06-10 20:29 Juha Manninen Status assigned => resolved
2021-06-10 20:29 Juha Manninen Resolution open => fixed
2021-06-10 20:29 Juha Manninen Fixed in Revision => r65191
2021-06-10 20:29 Juha Manninen Widgetset GTK 3 => GTK 3
2021-06-10 20:29 Juha Manninen Note Added: 0131230
2021-06-10 20:30 Juha Manninen Relationship added related to 0038942