Recent

Author Topic: [solved] which checkbox was clicked in TCheckListBox ?  (Read 2680 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
[solved] which checkbox was clicked in TCheckListBox ?
« on: January 29, 2018, 01:39:32 pm »
I'm using a TCheckListBox and want to know which one the user has just clicked. On Win/Linux clicking a checkbox also selects that item so you can look at ItemIndex when CheckListBox1ClickCheck fires. But on the Mac the selected item does not change when a checkbox is clicked.

I'm not sure if I should rely on that connection anyway, its certainly not documented anywhere that clicking a checkbox should select that item.

I can keep a separate list of which ones are ticked and then scan over the listbox and see which one has changed but that does seem messy !

Does anyone else know of any way to get an index to a clicked checkbox on TCheckListBox ?

Davo 
« Last Edit: January 30, 2018, 03:56:03 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: which checkbox was clicked in TCheckListBox ?
« Reply #1 on: January 29, 2018, 02:15:55 pm »
Code: Pascal  [Select][+][-]
  1. procedure TForm1.CheckListBox1ItemClick(Sender: TObject; Index: integer);
  2. begin
  3.   WriteLn('Index of clicked checkbox is ',Index,', Checked state is ',(Sender as TCheckListBox).Checked[Index]);
  4. end;

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: which checkbox was clicked in TCheckListBox ?
« Reply #2 on: January 29, 2018, 02:18:36 pm »
Yes, OnItemClick is the way + you can fill bugreport (if it is not already reported).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 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/

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: which checkbox was clicked in TCheckListBox ?
« Reply #3 on: January 30, 2018, 03:55:33 am »
Yep, thanks, thats definitly the solution. I just needed to search a bit harder !

I'll put something on the TCheckListBox wiki page, sadly its almost blank.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018