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" is pressed. Maybe a Jedi control would suffice, but hopefully there's some fix. Any help or anecdotes are appreciated.
BTW, I'm (still) using Delphi 7, not sure if this is an across the board conundrum.
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:
Hm, strange, I remember using this quite a few times with success. Perhaps you should try playing with the SpeedButton's
Down
property? I don't think it toggles automatically when you click it --- you should explicitly toggleDown
, I guess...[edit: replaced
Checked
withDown
--- TSpeedButton doesn't have aChecked
property, sorry!]knight_killer is correct. i can tell you it'll work in any version of delphi:
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.
I was searching for a solution for my problem and I think this is kind of the same one. I wanted to make a SpeedButton toggle the up and down state just like a switch, and I managed this by setting the properties:
Then in the
OnClick
event of the button I wrote:This toggles the button down when it's clicked and up when it's clicked again.
Hope it'll be of any help
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.