View Issue Details

IDProjectCategoryView StatusLast Update
0034396LazarusPatchpublic2018-10-08 21:25
ReporterAnton Kavalenka Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Summary0034396: gtk3: make TRadioGroup working
DescriptionPatch provided to make it work.

TRadioButton widgets now added to common list.

Workaround for 'HiddenRadioButton' simply does not create it.

Steps To ReproduceTest provided
TagsNo tags attached.
Fixed in Revisionr59262
LazTarget-
WidgetsetGTK 3
Attached Files

Activities

Anton Kavalenka

2018-10-06 17:51

reporter  

rgroup.diff (1,839 bytes)   
Index: gtk3widgets.pas
===================================================================
--- gtk3widgets.pas	(revision 59254)
+++ gtk3widgets.pas	(working copy)
@@ -680,8 +680,10 @@
   { TGtk3RadioButton }
 
   TGtk3RadioButton = class(TGtk3CheckBox)
+  private
   protected
     function CreateWidget(const Params: TCreateParams):PGtkWidget; override;
+    procedure InitializeWidget; override;
   public
   end;
 
@@ -790,7 +792,7 @@
 
 implementation
 uses Spin, gtk3int, gtk3procs, gtk3private, Gtk3CellRenderer, ExtDlgs, math,
-  CheckLst;
+  CheckLst, extctrls;
 
 function Gtk3EventToStr(AEvent: TGdkEventType): String;
 begin
@@ -6261,10 +6263,50 @@
 { TGtk3RadioButton }
 
 function TGtk3RadioButton.CreateWidget(const Params: TCreateParams): PGtkWidget;
+var
+  w:PGtkWidget;
+  ctl,Parent:TWinControl;
+  rb:TRadioButton;
+  pl:PGsList;
 begin
+  if Self.LCLObject.Name='HiddenRadioButton' then
+  	exit;
+
   Result := PGtkWidget(TGtkRadioButton.new(nil));
+
+  ctl:=Self.LCLObject;
+  if Assigned(ctl) then
+  begin
+  	Parent:=ctl.Parent;
+    if (Parent is TRadioGroup) and (TRadioGroup(Parent).Items.Count>0) then
+    begin
+      rb:=TRadioButton(Parent.Controls[0]);
+      if rb<>ctl then
+      begin
+
+      w:=TGtk3RadioButton(rb.Handle).Widget;
+      pl:=PGtkRadioButton(w)^.get_group;
+      PGtkRadioButton(Result)^.set_group(pl);
+      end;
+    end;
+  end;
 end;
 
+procedure TGtk3RadioButton.InitializeWidget;
+begin
+
+  if Self.LCLObject.Name='HiddenRadioButton' then
+  begin
+   exit;
+   { PGtkRadioButton(Self.Widget)^.set_group(nil);
+   // PGtkRadioButton(Self.Widget)^.set_inconsistent(true);
+  	PGtkRadioButton(Self.Widget)^.set_visible(false);}
+  end;
+  inherited InitializeWidget;
+
+
+end;
+
 { TGtk3CustomControl }
 
 function TGtk3CustomControl.CreateWidget(const Params: TCreateParams
rgroup.diff (1,839 bytes)   

Anton Kavalenka

2018-10-06 17:51

reporter  

laztest112.zip (129,092 bytes)

Anton Kavalenka

2018-10-06 21:15

reporter  

Juha Manninen

2018-10-07 10:39

developer   ~0111293

Applied with formatting changes. It works well, GTK3 is slowly becoming usable.
Thanks.

For future, it is even better if you create patches from the top level of Lazarus sources.

CudaText man

2018-10-07 15:15

reporter   ~0111305

>Workaround for 'HiddenRadioButton' simply does not create it.
what is the purpose of this special Name?

Anton Kavalenka

2018-10-07 18:34

reporter   ~0111312

At LCL level one excessive TRadioButton with that funny name is created inside a TRadioGroup to handle condition when ItemIndex=-1 (i.e. all radio buttons are unchecked except this one)

Unfortunately I can not hide this 'HiddenRadioButton', so I decided to disable handle creation for it.
IMO, being part of the group it cannot be hidden.

Issue History

Date Modified Username Field Change
2018-10-06 17:51 Anton Kavalenka New Issue
2018-10-06 17:51 Anton Kavalenka File Added: rgroup.diff
2018-10-06 17:51 Anton Kavalenka File Added: laztest112.zip
2018-10-06 21:15 Anton Kavalenka File Added: Здымак экрана, 2018-10-06 22-11-21.png
2018-10-07 10:35 Juha Manninen Assigned To => Juha Manninen
2018-10-07 10:35 Juha Manninen Status new => assigned
2018-10-07 10:39 Juha Manninen Fixed in Revision => r59262
2018-10-07 10:39 Juha Manninen LazTarget => -
2018-10-07 10:39 Juha Manninen Note Added: 0111293
2018-10-07 10:39 Juha Manninen Status assigned => resolved
2018-10-07 10:39 Juha Manninen Resolution open => fixed
2018-10-07 15:15 CudaText man Note Added: 0111305
2018-10-07 18:34 Anton Kavalenka Note Added: 0111312
2018-10-08 21:25 Anton Kavalenka Status resolved => closed