Is there a component like TSpeedButton that can receive the Focus? TSpeedButton cannot because it is derived from TGraphicsControl and not from TWinControl. But since the question "How do I make TSpeedButton receive the focus?" must have been asked a Gazillion times over the years, I can't believe that nobody has written a component that solves that problem. But my Google fu left me.
Is there a component like TSpeedButton that can receive the Focus? TSpeedButton cannot because it is derived from TGraphicsControl and not from TWinControl. But since the question "How do I make TSpeedButton receive the focus?" must have been asked a Gazillion times over the years, I can't believe that nobody has written a component that solves that problem. But my Google fu left me.
What I need is TSpeedButton's ability to stay down until pressed again, but it should take the focus and be pressed with the space bar.
This is about VCL only.
What I need is TSpeedButton's ability to stay down until pressed again, but it should take the focus and be pressed with the space bar.
This is about VCL only.
TBitBtn can receive focus, but I think it cannot stay down. If memory serves me right, Raize has a button that can.
ReplyDeleteJeroen Wiert Pluimers Indeed: TRzButton has properties AllowAllUp, Down and GroupIndex that implement the same behavior as the corresponding TSpeedButton properties.
ReplyDeleteOK, I should have mentioned that I don't want a component pack but a single component. And its license must be compatible with GExperts.
ReplyDeleteAfter experimenting a bit, I came up with the following possible solutions:
ReplyDelete1. Take TBitBtn, use the Picture of a TSpeedButton in Up and Down state as the Glyph. Works but is a bit ugly
2. Take a TColorButton (http://www.swissdelphicenter.ch/en/showcode.php?id=1100) and change it's background color depending on whether it's down or not. Could work if I find a colour that looks good.
3. Take a TBitBtn and use a custom glyph that looks like a round button, again in an Up and Down state. I think that one could work both technically and visually.
swissdelphicenter.ch - SwissDelphiCenter.ch : ...change a TButton's Color ?
Why not using a TCheckBox? It can receive the focus, toggles on space bar. Regession: Up/Down state is Checked/Unchecked.
ReplyDeleteAchim Kalwa the standard component would be either Checkbox (AllowAllUp = true) or RadioButton/RadioGroup (AllowAllUp = false). But they are just not as flexible, in particular I can't easily size and arrange them the way I'd like to.
ReplyDeleteWhat about a simple TButton and change the Imageindex for Up/Down. This can easily be achieved with a TAction in its OnUpdate event.
ReplyDeleteUwe Raabe TButton does not have an Image in Delphi 6. But that's basically my TBitBtn solution.
ReplyDelete+Thomas Mueller (dummzeuch I did a quick grep for the word allup
ReplyDeleteand found
TToolbarButton97.SetAllowAllUp
TcyDBAdvSpeedButton.CMButtonPressed cy librery
Codebot Class Library @ codebot.org - Open Source Delphi
in SpeedCtrls; has it too
and Developer Express Visual Component Library has it too
All are buttons
Thomas Mueller i just saw that
ReplyDeleteDownloads of the Codebot Controls have been removed
So since it was free get in touch i will send you the source
P.S they are all searched on D7
Thomas Mueller One more TFlatButton
ReplyDeleteI have all the sources - free.
shlomo abuisak I found the TFlatButton sources on GitHub (https://github.com/cust/delphi/tree/master/FlatStyle%20Component) , but apparently they require quite a lot of additional units and don't compile without changes (somebody adapted them to XE5, breaking backwards compatibility). I have a solution based on TBitBtn now. I'll see how far I get with that. If it works out, I'll blog about it. If not, I'll be contacting you regarding the sources.
ReplyDeleteplus.google.com - When you google for TSpeedButton and Focus a lot of hits are where people ask...
ReplyDeleteI'll see how it works out.
Attila Kovacs ich sollte definitiv öfter google.de verwenden, aber normalerweise ist es umgekehrt.
ReplyDeleteThomas Mueller I found an old archive of FlatStyle components dated from 2001 with sources. You can get the library from here github.com - pitfiend/FlatStyle
ReplyDeleteWe can suggest TscButton control from our StyleControls VCL (http://www.almdev.com). You can set TscButton.StyleKind = scbsToolButton, TscButton.CanFocused = True. This control has GroupIndex, AllowAllUp, RepeatClick, DropDownMenu, SplitButton and many others properties to get full analogue of speed button (tool button) with focus. Also, of course it has perfect themes and VCL Styles support!
ReplyDeleteAttila Kovacs I just tried the code you linked to. Yes, it works when klicking the mouse and as long as the focus stays on the button. But the button comes up again when pressed with the space bar or moving the focus to some other control. So, no solution either. Thanks for the hint anyway.
ReplyDeleteAttila Kovacs your source works BUT as i recall the button pressed is changing graphically to show the button is actually DOWN.
ReplyDeleteI used this feature a long time ago.
Attila Kovacs I tried that too: Same problem when the focus moves to a different control. Also, I made some changes to my original code (see new blog post). I'm pretty satisfied with the way it works now. It's simple and easy to understand.
ReplyDeleteThomas Mueller I tried to add your source as a component by putting on a form.
ReplyDeleteI get >>>> invalid class typecast.
Obviously i registered the component on the pallet.
Any idea? D10.2.1
Attila Kovacs As per Thomas Mueller demo this is what i ment
ReplyDelete