Discussion:
Question about TBitBtn
(too old to reply)
Andre
2008-06-04 17:20:09 UTC
Permalink
Hello,

I think it is something simple, but I coudn´t find the solution myself.

I want a bi-state button. I tried SpeedButton, but it didn´t respond to
the hotkey in its caption, so I forgot this one.

TButton doesn´t seem to have this funcionality, and then I go for
TBitBtn (wich I prefer, anyway).

But I can´t find the "Down" property of if! How do I use that. The help
for this TBitBtn even says, for the Glyph property that it has the
"Down" state. It accecpts 4 images in the glyph.

But I am lost on how to use it. I don´t wanna images (necessarily). I
just want it to toogle the pressed look each time the user clicks.

Can you help me?

Thanks.

André
Andre
2008-06-05 14:52:53 UTC
Permalink
Post by Andre
I want a bi-state button. I tried SpeedButton, but it didn´t respond to
the hotkey in its caption, so I forgot this one.
I missed something here. It *DID* respond to the hotkey on its caption,
but it didn´t changed the Down property as I expected it to.

Any ideia why this happens?
Remy Lebeau (TeamB)
2008-06-05 17:19:33 UTC
Permalink
Post by Andre
I missed something here. It *DID* respond to the hotkey
on its caption, but it didnŽt changed the Down property as I
expected it to.
It is not supposed to. You can set the property manually, though, ie:

void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
SpeedButton1->Down = !SpeedButton1->Down;
}


Gambit
Andre
2008-06-06 15:33:43 UTC
Permalink
Post by Remy Lebeau (TeamB)
Post by Andre
I missed something here. It *DID* respond to the hotkey
on its caption, but it didn´t changed the Down property as I
expected it to.
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
SpeedButton1->Down = !SpeedButton1->Down;
}
The problem with this solution is that when the user clicks with the
mouse, the Down property is already changed (so it would reset it). When
the keyboard is used, it would work as intended.

I don´t know how to tell wich situation happened.

Since you said it is not supposed to, would it be good to send some code
for you all to see?

Thanks, Gambit.
Remy Lebeau (TeamB)
2008-06-06 16:16:51 UTC
Permalink
Post by Andre
The problem with this solution is that when the user clicks
with the mouse, the Down property is already changed (so
it would reset it). When the keyboard is used, it would work
as intended.
TSpeedButton is not a windowed control, so it can never receive keyboard
input to begin with.


Gambit
Andre
2008-06-11 14:59:47 UTC
Permalink
Post by Remy Lebeau (TeamB)
TSpeedButton is not a windowed control, so it can never receive keyboard
input to begin with.
And if I want ao bi stable button that receives keyboard input should I
write a new class? :/
Remy Lebeau (TeamB)
2008-06-06 16:18:27 UTC
Permalink
Post by Andre
I want a bi-state button
<snip>
Post by Andre
I just want it to toogle the pressed look each time the user clicks.
Using TSpeedButton, simply set the AllowAllUp property to true, and the
GroupIndex to a non-zero value. The button will then toggle its Down
property automtically when clicked without any extra code needed.


Gambit
Andre
2008-06-11 15:00:49 UTC
Permalink
Post by Remy Lebeau (TeamB)
Post by Andre
I want a bi-state button
<snip>
Post by Andre
I just want it to toogle the pressed look each time the user clicks.
Using TSpeedButton, simply set the AllowAllUp property to true, and the
GroupIndex to a non-zero value. The button will then toggle its Down
property automtically when clicked without any extra code needed.
I knew. But the problem is the keyboard input, as you also said.
Tom420
2008-08-03 19:39:44 UTC
Permalink
Post by Andre
and then I go for
TBitBtn (wich I prefer, anyway).
But I can´t find the "Down" property of if!
I believe the Checked property of the TBitBtn does what you intend.

Hope this helps,
Tom :)

Loading...