Recent

Author Topic: TCheckListBox events triggered oddly (Win10)  (Read 3828 times)

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
TCheckListBox events triggered oddly (Win10)
« on: September 03, 2018, 01:20:45 am »
There are three single click-related events in TCheckListBox
OnCLick, which is fired when any part of the Control is clicked
OnClickCheck, which is fired when the check box is clicked
OnItemClick, which is fired when any part of the entry is clicked (check box or item text) is clicked. This seems to duplicate OnClick

If you click the check region all three are fired (OnClick, then OnClickCheck, then OnItemClick)

None of these are fired by a single click on the text.  Wouldn't this be expected to fire OnItemClick?
If OnClick is handled, OnDblClick is never called. Is this the expected behaviour?

Thanks!


 
« Last Edit: September 03, 2018, 01:40:45 am by PaulRowntree »
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: TCheckListBox events triggered oddly (Win10)
« Reply #1 on: September 03, 2018, 02:55:23 am »
What widgetset? I tested on Qt and GTk2 and:

OnClick is fired when any part of the Control is clicked.
OnClickCheck is fired when the check box is clicked.
OnItemClick is also fired when the check box is clicked - duplicate of OnClickCheck.

If I click the check region all three are fired but with different order on Qt and GTk2.
Only OnClick is fired when I click text.

OnDblClick is fired as expected in whole area (checkbox, text or the rest).

EDIT: Win10, I noticed now. BTW, Delphi has no OnItemClick.

EDIT2: You can visit bugtracker and search for "CheckListBox", there are two pages of bugreports (but 90% are resolved or closed).
« Last Edit: September 03, 2018, 03:17:39 am by Blaazen »
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/

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: TCheckListBox events triggered oddly (Win10)
« Reply #2 on: September 03, 2018, 03:21:18 am »
What widgetset? I tested on Qt and GTk2 and:

OnClick is fired when any part of the Control is clicked.
OnClickCheck is fired when the check box is clicked.
OnItemClick is also fired when the check box is clicked - duplicate of OnClickCheck.

If I click the check region all three are fired but with different order on Qt and GTk2.
Only OnClick is fired when I click text.

OnDblClick is fired as expected in whole area (checkbox, text or the rest).
Thanks for the quick reply Blaazen
1) Widget set is Win32.  The application is Win64, Laz 1.8.3

2) DoubleClick : This is odd.  I put a ShowMessage() in each of the handlers to show when it is called.  With those ShowMessage lines disabled, I see the dblClick being fired as you say.  But when ShowMessage lines are enabled, there is no message coming from the dblClick handler.  I do see the ShowMessage dialog window flash oddly under these conditions (and the windows sounds is heard), but no dblClick ShowMessage.  Weird, but I presume OK once we get past diagnostics
3) Confirmed that all three events are fired when the checkbox region is clicked.4) Confirmed that ItemCheck is called when the check region is clicked

Would you expect that ItemClicked should be fired when the text is clicked?  If not, it seems redundant : what is it for?Cheers!pr
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: TCheckListBox events triggered oddly (Win10)
« Reply #3 on: September 03, 2018, 03:45:05 am »
2) DoubleClick : This is odd.  I put a ShowMessage() in each of the handlers to show when it is called.  With those ShowMessage lines [...]
Instead of ShowMesssage(), try setting a more permanent (and normal) response when each is called. For example a couple of TLabels, one for each event, or a multiline edit control, if you want to see in which order the events are shot. Doing it this way would assure you of whether DblClick is indeed called. Can't help more, since I don't have Windows boxes around here ATM.

One other little thing: please, don't use red-colored text: it becomes almost unreadable over the standard forum background---at least for people (like me) with bad sight. Bold text is enough to emphasize.

ETA: Wait widgetset is Win32 and the application is 64 bit? That can't be. Or do you mean the application is 32 bit but running on Windows 10 64bit?
« Last Edit: September 03, 2018, 03:51:32 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: TCheckListBox events triggered oddly (Win10)
« Reply #4 on: September 03, 2018, 03:50:08 am »
I guess that OnDblClick can't be test with ShowMessage. It needs two clicks with small interval and if there is ShowMessage after the first OnClick then it is lost.

Try to add ListBox on the form and add lines "OnClick" or "OnDblClick" to it instead of ShowMessages.
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/

PaulRowntree

  • Full Member
  • ***
  • Posts: 132
    • Paul Rowntree
Re: TCheckListBox events triggered oddly (Win10)
« Reply #5 on: September 03, 2018, 03:58:12 am »
I guess that OnDblClick can't be test with ShowMessage. It needs two clicks with small interval and if there is ShowMessage after the first OnClick then it is lost.

Try to add ListBox on the form and add lines "OnClick" or "OnDblClick" to it instead of ShowMessages.
I think you're right.  The dblClick does work as expected.
Any thoughts on ItemClick ?  I would really like to know if the text has been selected, apart from the checkbox.Cheers!
Paul Rowntree
- coding for instrument control, data acquisition & analysis, CNC systems

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: TCheckListBox events triggered oddly (Win10)
« Reply #6 on: September 03, 2018, 04:25:59 am »
Any thoughts on ItemClick ?  I would really like to know if the text has been selected, apart from the checkbox.Cheers!

If just to discard a more general bug, can you try to see if it works in a simple ListBox?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: TCheckListBox events triggered oddly (Win10)
« Reply #7 on: September 03, 2018, 05:02:59 am »
I guess that OnDblClick can't be test with ShowMessage. It needs two clicks with small interval and if there is ShowMessage after the first OnClick then it is lost.

Try to add ListBox on the form and add lines "OnClick" or "OnDblClick" to it instead of ShowMessages.
I think you're right.  The dblClick does work as expected.
Any thoughts on ItemClick ?  I would really like to know if the text has been selected, apart from the checkbox.Cheers!
Windows 7 lazarus 1.8.2 onitemclick is not raised when not clicked on the check box here is my test code

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   ListBox1.Clear;
  4. end;
  5.  
  6. procedure TForm1.Append(const aText :String);
  7. begin
  8.   ListBox1.Items.Add(aText);
  9. end;
  10.  
  11. procedure TForm1.CheckListBox1Click(Sender :TObject);
  12. var
  13.   vMousePos :TPoint;
  14.   vItemClicked:Integer;
  15. begin
  16.   Append('OnClick');
  17.   vMousePos := TControl(Sender).ScreenToClient(Mouse.CursorPos);
  18.   vItemClicked := CheckListBox1.ItemAtPos(vMousePos,True);
  19.   if vItemClicked > -1 then Append('OnClick Item Clicked :' + IntToStr(vItemClicked));
  20. end;
  21.  
  22. procedure TForm1.CheckListBox1ClickCheck(Sender :TObject);
  23. begin
  24.   Append('OnClickCheck');
  25. end;
  26.  
  27. procedure TForm1.CheckListBox1DblClick(Sender :TObject);
  28. begin
  29.   Append('OnDblClick');
  30. end;
  31.  
  32. procedure TForm1.CheckListBox1ItemClick(Sender :TObject; Index :integer);
  33. begin
  34.   Append('OnItemClick : '+ CheckListBox1.Items[Index]);
  35. end;
  36.  
  37.  
Its easy to reproduce the layout just drop a checklistbox, a listbox and a button on the form and fill in events shown above and of course a couple of items in the check list box
Attached a gif that shows my results.
« Last Edit: September 03, 2018, 05:05:06 am by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

ASerge

  • Hero Member
  • *****
  • Posts: 2242
Re: TCheckListBox events triggered oddly (Win10)
« Reply #8 on: September 03, 2018, 08:34:04 pm »
If you look at the sources, you can see that the OnItemClick and OnClickCheck events are called at the same time. Not very clear why made duplication. By the way, in Delphi no OnItemClick (in VCL).

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: TCheckListBox events triggered oddly (Win10)
« Reply #9 on: September 03, 2018, 08:43:26 pm »
By the way, in Delphi no OnItemClick (in VCL).

IIRC correctly---I may not---Delphi had OnSelectionChange or something similarly called that performed the same task, at lest for TListBox. Can't investigate much more: most of my development machines have apparently decided to go on strike: something about the heat, I think... :(
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018