Recent

Author Topic: [SOLVED] TComboBox with extra button anyone?  (Read 393 times)

EganSolo

  • Full Member
  • ***
  • Posts: 202
[SOLVED] TComboBox with extra button anyone?
« 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!

« Last Edit: February 24, 2021, 01:34:09 am by EganSolo »

dseligo

  • Jr. Member
  • **
  • Posts: 82
Re: TComboBox with extra button anyone?
« Reply #1 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

jamie

  • Hero Member
  • *****
  • Posts: 4199
Re: TComboBox with extra button anyone?
« Reply #2 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..
The only true wisdom is knowing you know nothing

Blaazen

  • Hero Member
  • *****
  • Posts: 3029
  • POKE 54296,15
    • Eye-Candy Controls
Re: TComboBox with extra button anyone?
« Reply #3 on: February 23, 2021, 11:26:42 pm »
You can install Eye-Candy Controls. There are TECComboBtn and TECColorCombo which do exactly that.
Lazarus 2.1.0 r64546 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

jamie

  • Hero Member
  • *****
  • Posts: 4199
Re: TComboBox with extra button anyone?
« Reply #4 on: February 23, 2021, 11:32:58 pm »
There you go, "Jim Dandy  to the rescue" !
The only true wisdom is knowing you know nothing

EganSolo

  • Full Member
  • ***
  • Posts: 202
Re: TComboBox with extra button anyone?
« Reply #5 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.

jamie

  • Hero Member
  • *****
  • Posts: 4199
Re: [SOLVED] TComboBox with extra button anyone?
« Reply #6 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!
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018