I\'m not sure why the TSpeedButton has this property but when a TSpeedButton is the only button of a given groupindex, it doesn\'t stay pressed, whether or not \"AllowAllUp\
To get this to work, you can't just toggle the Down property, because it is always down in the OnClick event. You need to have another value:
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
MyBoolProperty := not MyBoolProperty;
SpeedButton1.Down := MyBoolProperty;
end;
I just tried that in Delphi 7 (Build 4.453):
TSpeedButton
to formAllowAllUp := true;
GroupIndex := 1;
When clicking the button it toggles its down state without any other code needed.
Delphi does the work for you so "don't write ANY CODE".
In the IDE select ALL of your SpeedButtons that you want to operate as a group and then set the whole group's "GroupIndex" to something other than "0" and you are done -- with NO CODE -- NADA!!
The trick is to set the GroupIndex to a unique value and set AllowAllUp to true. If you forget the first, it will not stay down, if you forget the second, it will not stay up, once it has been down.
Set AllowAllUp to True.
Set GroupIndex to non 0.
To keep it all in the OnClick, try
with Speedbutton1 do
begin
if tag = 1 then tag := 0 else tag := 1;
down := (tag = 1);
end;