Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a Delphi TSpeedButton stay pressed if it's the only one in the group

Tags:

button

delphi

vcl

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.

like image 562
Peter Turner Avatar asked Oct 14 '08 20:10

Peter Turner


3 Answers

I have no D7 here, but in D2006 a Speedbutton stays down if the GroupIndex has a value > 0.

If this is not the behaviour you wish, you can set the Down-Property manually in the OnClick-Eventhandler (make sure, that the GroupIndex is 0).

like image 87
Roman Ganz Avatar answered Sep 19 '22 22:09

Roman Ganz


I just tried that in Delphi 7 (Build 4.453):

  • create new application
  • add TSpeedButton to form
  • set AllowAllUp := true;
  • set GroupIndex := 1;
  • run application

When clicking the button it toggles its down state without any other code needed.

like image 14
Uwe Raabe Avatar answered Sep 23 '22 22:09

Uwe Raabe


knight_killer is correct. i can tell you it'll work in any version of delphi:

object SpeedButton1: TSpeedButton
  Left = 152
  Top = 384
  Width = 23
  Height = 22
  AllowAllUp = True
  GroupIndex = 99
end
like image 2
X-Ray Avatar answered Sep 23 '22 22:09

X-Ray