Lazarus

Programming => LCL => Topic started by: EganSolo on February 23, 2021, 09:41:00 am

Title: [SOLVED] TComboBox with extra button anyone?
Post by: EganSolo on February 23, 2021, 09:41:00 am
I'm in need of a TComboBox with an extra button, much like what you see happen in the Object Inspector when you're editing a color: the drop-down allows you to select a standard color and the button opens up a color dialog window.

I want to mimic that exact behavior in my code. I could, I suppose, create a form, or even a panel, set a combobox and a button on them, rig the thing to act as an editor in a grid, but there would be some wiring that I would need to take care of. I've looked around for an existing widget that does that and couldn't find it (Googled it, really).

Any thoughts would be welcome!

Title: Re: TComboBox with extra button anyone?
Post by: dseligo on February 23, 2021, 10:55:42 am
You can see how it's done in Object Inspector. Unit and form of Object Inspector are located in Lazarus folder, in /components/ideintf/objectinspector.pp
Title: Re: TComboBox with extra button anyone?
Post by: jamie on February 23, 2021, 10:52:02 pm
I'm in need of a TComboBox with an extra button, much like what you see happen in the Object Inspector when you're editing a color: the drop-down allows you to select a standard color and the button opens up a color dialog window.

I want to mimic that exact behavior in my code. I could, I suppose, create a form, or even a panel, set a combobox and a button on them, rig the thing to act as an editor in a grid, but there would be some wiring that I would need to take care of. I've looked around for an existing widget that does that and couldn't find it (Googled it, really).

Any thoughts would be welcome!

Now you are being Lazy!  :-[

 Make a Frame with what you need, from there on you can use it all over.
 Set the anchors on the controls so the button will stay with the combobox

 They aren't exactly like making a control but its close enough..
Title: Re: TComboBox with extra button anyone?
Post by: Blaazen on February 23, 2021, 11:26:42 pm
You can install Eye-Candy Controls. There are TECComboBtn and TECColorCombo which do exactly that.
Title: Re: TComboBox with extra button anyone?
Post by: jamie on February 23, 2021, 11:32:58 pm
There you go, "Jim Dandy  to the rescue" !
Title: Re: TComboBox with extra button anyone?
Post by: EganSolo on February 24, 2021, 01:33:53 am
Thank you guys for your very helpful answer:

dseligo: thanks for pointing out the path to the source of object inspector! You got me curious and I will take a look.
Jamie: Love the idea of the frame as a pseudo-component. I have other things I need to build and that will help.
Blaazen: that's the answer I was hoping to get :)

Much appreciated, everyone.
Title: Re: [SOLVED] TComboBox with extra button anyone?
Post by: jamie on February 24, 2021, 10:46:46 pm
if you are still playing around there is also the TFlowPanel where you can combine the controls you need at design time!
TinyPortal © 2005-2018