lcl: fixed TSpeedButton with Action and changing Action.ImageIndex

This commit is contained in:
mattias 2021-11-05 11:47:57 +01:00
parent c8bfe6c6cd
commit adafca05c0

View File

@ -432,8 +432,10 @@ begin
if (NewAct.ActionList = nil) or (NewAct.ImageIndex < 0) then Exit; if (NewAct.ActionList = nil) or (NewAct.ImageIndex < 0) then Exit;
Imgs := NewAct.ActionList.Images; Imgs := NewAct.ActionList.Images;
if (Imgs = nil) or (NewAct.ImageIndex >= Imgs.Count) then Exit; if (Imgs = nil) or (NewAct.ImageIndex >= Imgs.Count) then Exit;
ImgRes := Imgs.ResolutionForPPI[ImageWidth,Font.PixelsPerInch,GetCanvasScaleFactor]; Images := Imgs;
ImgRes.GetBitmap(NewAct.ImageIndex, Glyph); ImageIndex := NewAct.ImageIndex;
//ImgRes := Imgs.ResolutionForPPI[ImageWidth,Font.PixelsPerInch,GetCanvasScaleFactor];
//ImgRes.GetBitmap(NewAct.ImageIndex, Glyph);
end; end;
end; end;
@ -488,13 +490,13 @@ function TCustomSpeedButton.IsGlyphStored: Boolean;
var var
act: TCustomAction; act: TCustomAction;
begin begin
result := true; Result := true;
if Action <> nil then if Action <> nil then
begin begin
act := TCustomAction(Action); act := TCustomAction(Action);
if (act.ActionList <> nil) and (act.ActionList.Images <> nil) and if (act.ActionList <> nil) and (act.ActionList.Images <> nil) and
(act.ImageIndex >= 0) and (act.ImageIndex < act.ActionList.Images.Count) then (act.ImageIndex >= 0) and (act.ImageIndex < act.ActionList.Images.Count) then
result := false; Result := false;
end; end;
end; end;
@ -502,7 +504,7 @@ procedure TCustomSpeedButton.SetShowCaption(const AValue: boolean);
begin begin
if FShowCaption=AValue then exit; if FShowCaption=AValue then exit;
FShowCaption:=AValue; FShowCaption:=AValue;
invalidate; Invalidate;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------