My Application has several TSpeedButtons
with which to choose a color and I want each choice to be shown by the color of the TSpeedButton
.
I found this answer on Stackoverflow on how to change the color of a TButton
. The second answer (change colors dynamically) appears to be the solution I am looking for. It reads as follows:
var r: TRectangle;
begin
// Find the background TRectangle style element for the button
r := (Button1.FindStyleResource('background') as TRectangle);
if Assigned(r) then
begin
r.Fill.Color := claBlue;
end;
end;
This does not work anymore (i use XE5, this is XE2?). It generates an exception at the r := ...
statement with:
"illegal cast".
The FindStyleResource returns a FMXObject.
TRectangle is a TShape->TControl->TFMXObject.
I can cast to TControl but not to TShape. In case you wonder, Button1 is a TButton.
Does anyone know how I do change the color of a TSpeedButton
?
As an aside: is there a way to determine which type of object exactly is beging returned? I couldn't find out in the debugger.