View Issue Details

IDProjectCategoryView StatusLast Update
0038135LazarusLCLpublic2020-11-30 21:24
ReporterWallaby Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.1 (SVN) 
Summary0038135: Changing TAction.ImageIndex does not propogate to TSpeedButton's image index.
DescriptionThere seems to be an issue in linking an action to a speed button. I have created a test project with one speed button, one image list with two images and an action.

When I change the action's Caption property, the speed button's caption is updated correctly.

However when I change the action's ImageIndex property, the speed button's image is not updated. The same can be observed in design time when changing the action's ImageIndex.
Steps To ReproduceOpen the sample project and click the button.

Expected behaviour: caption and image change.
Actual behaviour: caption changes, image does NOT
TagsNo tags attached.
Fixed in Revisionr64165
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Wallaby

2020-11-27 05:33

reporter  

test.zip (110,001 bytes)

Anton Kavalenka

2020-11-27 20:19

reporter   ~0127213

Patch fixes problem
speedbutton.diff (1,518 bytes)   
Index: lcl/buttons.pp
===================================================================
--- lcl/buttons.pp	(revision 64160)
+++ lcl/buttons.pp	(working copy)
@@ -290,9 +290,11 @@
     procedure AssignClient(AClient: TObject); override;
     procedure SetGroupIndex(Value: Integer); override;
     procedure SetChecked(Value: Boolean); override;
+    procedure SetImageIndex(Value: Integer); override;
   public
     function IsCheckedLinked: Boolean; override;
     function IsGroupIndexLinked: Boolean; override;
+    function IsImageIndexLinked: Boolean; override;
   end;
 
   { TCustomSpeedButton }
Index: lcl/include/speedbutton.inc
===================================================================
--- lcl/include/speedbutton.inc	(revision 64160)
+++ lcl/include/speedbutton.inc	(working copy)
@@ -1224,6 +1224,12 @@
     (SpeedButton.GroupIndex = (Action as TCustomAction).GroupIndex);
 end;
 
+function TSpeedButtonActionLink.IsImageIndexLinked: Boolean;
+begin
+  Result := inherited IsImageIndexLinked and
+    (TSpeedButton(FClient).ImageIndex = (Action as TCustomAction).ImageIndex);
+end;
+
 procedure TSpeedButtonActionLink.SetGroupIndex(Value: Integer);
 begin
   if IsGroupIndexLinked then TCustomSpeedButton(FClient).GroupIndex := Value;
@@ -1234,7 +1240,13 @@
   if IsCheckedLinked then TCustomSpeedButton(FClient).Down := Value;
 end;
 
+procedure TSpeedButtonActionLink.SetImageIndex(Value: Integer);
+begin
+  if IsImageIndexLinked then
+    TSpeedButton(FClient).ImageIndex := Value;
+end;
 
speedbutton.diff (1,518 bytes)   

Wallaby

2020-11-28 06:00

reporter   ~0127223

That patch helps, thank you. Devs, please merge it with the trunk.

Anton Kavalenka

2020-11-30 19:48

reporter   ~0127276

ping @JuhaManninen

Juha Manninen

2020-11-30 21:24

developer   ~0127280

Applied, thanks.

BTW, patch command refused to apply it :
 $ patch -p0 < ~/patch/speedbutton.diff
 patching file lcl/buttons.pp
 patching file lcl/include/speedbutton.inc
 patch: **** unexpected end of file in patch

and indeed the last hunk ends without the trailing existing lines for some reason. It was a small patch and I could easily autogenerate the function bodies and then copy the code. No problem.

Issue History

Date Modified Username Field Change
2020-11-27 05:33 Wallaby New Issue
2020-11-27 05:33 Wallaby File Added: test.zip
2020-11-27 20:19 Anton Kavalenka Note Added: 0127213
2020-11-27 20:19 Anton Kavalenka File Added: speedbutton.diff
2020-11-28 06:00 Wallaby Note Added: 0127223
2020-11-30 19:48 Anton Kavalenka Note Added: 0127276
2020-11-30 21:09 Juha Manninen Assigned To => Juha Manninen
2020-11-30 21:09 Juha Manninen Status new => assigned
2020-11-30 21:24 Juha Manninen Status assigned => resolved
2020-11-30 21:24 Juha Manninen Resolution open => fixed
2020-11-30 21:24 Juha Manninen Fixed in Revision => r64165
2020-11-30 21:24 Juha Manninen LazTarget => -
2020-11-30 21:24 Juha Manninen Widgetset Win32/Win64 => Win32/Win64
2020-11-30 21:24 Juha Manninen Note Added: 0127280