Recent

Author Topic: [SOLVED] TCheckComboBox -- Keeping the dropdown list visible for multi-checks?  (Read 1154 times)

EganSolo

  • Sr. Member
  • ****
  • Posts: 395
TCheckComboBox closes its drop-down list after each check. Is there a way to keep the drop down list visible to perform multiple checks before closing it?
« Last Edit: November 26, 2025, 09:31:03 am by EganSolo »

wp

  • Hero Member
  • *****
  • Posts: 13483
Re: TCheckComboBox -- Keeping the dropdown list visible for multi-checks?
« Reply #1 on: November 25, 2025, 04:32:59 pm »
Yes, the LCL TCheckCombobox has some issues... In my package ExCtrls, there is a rewritten TCheckComboboxEx (having a different inheritance) in which the dropdown only closes upon a double-click, a click outside or by pressing ENTER or ESC (which undoes the checks made while drop-down). See its wiki article in https://wiki.freepascal.org/ExCtrls#TCheckComboBoxEx

The unit is standalone, i.e. you can simply copy it into your project folder and create the combobox at runtime - no need for installation of the package.

The package is at https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/exctrls/ (use svn or download the zipped snapshot); or - if you only want the unit, download it from this link: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/exctrls/source/excheckcombo.pas
« Last Edit: November 25, 2025, 05:31:05 pm by wp »

dsiders

  • Hero Member
  • *****
  • Posts: 1592
Re: TCheckComboBox -- Keeping the dropdown list visible for multi-checks?
« Reply #2 on: November 25, 2025, 04:54:50 pm »
TCheckComboBox closes its drop-down list after each check. Is there a way to keep the drop down list visible to perform multiple checks before closing it?

Not that I've found. But TCheckComboBoxEx (in the ExCtrls package) works as you described.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4709
  • I like bugs.
Re: TCheckComboBox -- Keeping the dropdown list visible for multi-checks?
« Reply #3 on: November 25, 2025, 05:30:13 pm »
In my package ExCtrls, there is a rewritten TCheckComboboxEx
Maybe we should replace the TCheckComboBox in LCL with your control.
TCheckComboBox user experience is so poor that nobody wants to use it. Incidentally I also studied it during my ToDoList changes.
Delphi compatibility is not an issue because Delphi does not have TCheckComboBox AFAIK.
Are there other issues that prevent moving it to LCL?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 13483
Re: TCheckComboBox -- Keeping the dropdown list visible for multi-checks?
« Reply #4 on: November 25, 2025, 05:49:40 pm »
Are there other issues that prevent moving it to LCL?
I just ran Delphi 12 and you are right, there is not TCheckCombobox.

But because it is a new control I did not take care of compatibility with the existing TCheckCombobox, and thus replacing TCheckCombobox by TCheckComboboxEx will very probably break user code. The visual appearance is certainly different: While TCheckCombobox just displays the selected item (along with the checked/unchecked checkbox), TCheckComboboxEx displays a list of all checked items.


EganSolo

  • Sr. Member
  • ****
  • Posts: 395
Re: TCheckComboBox -- Keeping the dropdown list visible for multi-checks?
« Reply #5 on: November 26, 2025, 09:30:47 am »
Wp,
 Thank you so much for your package! I’m looking forward to leveraging these well-thought-out controls in my apps! Allowing the image list to create grayed versions of the glyph and even recoloring them, now that’s nifty! The ability of the message boxes to center over the app’s main form resolves a minor (yet pesky) pain point I was having with MessageDlg. Granted, I was being lazy, not searching for the solution, but your controls take care of it. The progress and status bars are beautifully designed, too. Overall, a great addition!
  One very minor issue with the ButtonsEx project: The compiler expected a resource file that was not found. The problem might be on my end, but I thought I'd mention it.

  Concerning TCheckComboBoxEx, I did a drop-in replacement with TCheckComboBox without a hitch. Here are the two methods I used to load and retrieve values from TCheckComboBox, which worked as-is with TCheckComboBoxEx. The only change I introduced was switching the formal param to TCheckComboBoxEx.

  I would second the opinions expressed here to include TCheckComboBoxEx into the standard distro. To allay concerns over breaking code, perhaps it would make sense to add it to the Additional Palette and flag TCheckComboBox as deprecated for a few releases before retiring it completely?

  In all cases, thank you for your great package! It's what I was looking for.

Code: Pascal  [Select][+][-]
  1. procedure TFilterEditor.DoLoadCheckComboBox(const ccb: TCheckComboBoxEx; const values: TStringList);
  2. var i: integer;
  3.     anItem : String;
  4.     b      : Boolean;
  5. begin
  6.   with ccb do
  7.   If Values.Count = 0
  8.   then CheckAll(cbUnchecked,{AAllowGrayed =} False, {AAllowDisabled=}False)
  9.   else for i := 0 to Items.Count -1 do
  10.        begin
  11.          anItem := Items[i];
  12.          b := Values.IndexOf(anItem) > -1;
  13.          Checked[i] := b;
  14.        end;
  15. end;
  16.  
  17. procedure TFilterEditor.DoSaveCheckComboBox(const ccb: TCheckComboBoxEx; const Values: TStringList);
  18. var i: integer;
  19.     anItem : String;
  20.     b      : Boolean;
  21. begin
  22.   Values.Clear;
  23.   with ccb do
  24.   for i := 0 to Items.Count -1 do
  25.   begin
  26.     b := Checked[i];
  27.     If b
  28.     then begin
  29.       anItem := Items[i];
  30.       Values.Add(anItem);
  31.     end;
  32.   end;
  33. end;
  34.  


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4709
  • I like bugs.
Re: TCheckComboBox -- Keeping the dropdown list visible for multi-checks?
« Reply #6 on: November 26, 2025, 10:48:56 am »
  I would second the opinions expressed here to include TCheckComboBoxEx into the standard distro. To allay concerns over breaking code, perhaps it would make sense to add it to the Additional Palette and flag TCheckComboBox as deprecated for a few releases before retiring it completely?
My idea was to rename the component's type and replace the current TCheckComboBox with it.
It makes no sense to keep 2 similar components in LCL, one of them working poorly. It would only create confusion and waste people's time when they try to figure out which component to use.
If the properties are more or less the same, it should be an easy port. This time Delphi compatibility is not an issue as it is with many components.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 13483
Re: TCheckComboBox -- Keeping the dropdown list visible for multi-checks?
« Reply #7 on: November 26, 2025, 11:05:17 am »
  I would second the opinions expressed here to include TCheckComboBoxEx into the standard distro. To allay concerns over breaking code, perhaps it would make sense to add it to the Additional Palette and flag TCheckComboBox as deprecated for a few releases before retiring it completely?
My idea was to rename the component's type and replace the current TCheckComboBox with it.
It makes no sense to keep 2 similar components in LCL, one of them working poorly. It would only create confusion and waste people's time when they try to figure out which component to use.
If the properties are more or less the same, it should be an easy port. This time Delphi compatibility is not an issue as it is with many components.
I can look over the component and adjust it with a replacement of TCheckCombobox in mind. One thing, I think, which cannot be changed it the inheritance: While TCheckCombobox inherits from TCustomCombobox, TCheckComboboxEx inherits from TCustomEditButton; therefore, when a user iterates over all TCustomComboboxes he will not find TCheckComboboxEx.

Maybe to prepare the transition and to document why this was changed: Could somebody file a bugreport/feature request for replacing TCheckCombobox/TCheckComboboxEx?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4709
  • I like bugs.
I tested TCheckComboboxEx with different widgetsets. With LCL-GTK3 the list opens in a wrong place.
This is probably a bug in LCL-GTK3 that manifests itself in other situations, too.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 13483
Fixed it: the dropdown top/left corner had been calculated in TCheckComboBoxEx.ShowPopup by ControlToScreen(0, Height) - using ClientToScreen fixes the issue. TBH, I never understood what's the difference between the two...

There is another issue in all Linux widgetsets: It is not possible to check an item by pressing the SPACE bar. This behaviour is inherited from TCheckListbox where this does not work either...

dsiders

  • Hero Member
  • *****
  • Posts: 1592
Fixed it: the dropdown top/left corner had been calculated in TCheckComboBoxEx.ShowPopup by ControlToScreen(0, Height) - using ClientToScreen fixes the issue. TBH, I never understood what's the difference between the two...

There is another issue in all Linux widgetsets: It is not possible to check an item by pressing the SPACE bar. This behaviour is inherited from TCheckListbox where this does not work either...

Where should bug reports be sent for other issues?  The lazarus-ccr bug tracker?

wp

  • Hero Member
  • *****
  • Posts: 13483
TCheckListbox is part of Lazarus - report bugs for it in the regular bug tracker. TCheckComboBoxEx and other components of the ExCtrls package are on CCR - report bugs in the CCR section of the Lazarus bugtracker. Bugs in any other third-party components which are not on CCR should be reported to the package repository directly, or here to the forum.

 

TinyPortal © 2005-2018