2
votes

How do I set a TSpeedButton (on a TToolbar) to look pressed down? It's only highlighted when clicking but gets normal when the mouse leaves it. I set the property Stayspressed to True and indeed the property IsPressed becomes and stays True, but this state is not visible.

2

2 Answers

3
votes

What style are you using? Some of the included ones do not have every effect included.

First, revert back to the windows style. If that works, then it's definitely a styling issue, rather than a code issue.

If you want to add an effect (actually an animation) to another style:

  • Right click on a button and select Edit Default Style.
  • Find the Fill.Color property of the Rectangle you want to show the anmimation.
  • Click the animation icon and add a TColorAnimation
  • Set: the StartValue (the existing value).
  • The StopValue
  • The Trigger: IsPressed=True

  • Repeat the above to add a second animation with the Start and StopValues reversed and Trigger of IsPressed=False

0
votes

This is a tough one - the standard TButton style includes effects which work - the button will look pressed when "IsPressed" is true. However, other styles (and especially your own) can be much more problematic. I have found the best solution is to have 2 styles and change the style when the button is pressed.

I found it pretty impossible to get "mouseover" animation to work with "pressed" animation in buttons - normally you want to highlight the button slightly when the mouse passes over and then add an effect when you press - especially when you don't want the default shadow effect but a colour effect (which I prefer, I don't like the inner shadow effect of a default button press), but I always seemed to end up with issues. Either one effect wouldn't fire OR the button state wouldn't return to what you'd expect (visually I mean).

My advice - add a little bit of extra code to change the style for the pressed button, you might go mad otherwise :-)