Recent

Author Topic: TListBox and its OnSelectionChange event  (Read 1371 times)

wp

  • Hero Member
  • *****
  • Posts: 11468
Re: TListBox and its OnSelectionChange event
« Reply #15 on: September 08, 2023, 10:34:48 am »
I did not yet check this patch, but does it work in case of multiselection where we need exactly that second click on a previously selected item if the user wants to unselect it. Is this still working?
I confirm: Basic operation is correct. But when MultiSelect is true the patch breaks toggling of the same selected item: Run attached demo. Check the "Multi-select" box. Click on item "5" - the memo registers the OnSelectionChange. Hold CTRL down and click on item "5" again - the selection changes, but the OnSelectionChange is not registered in the memo.

jamie

  • Hero Member
  • *****
  • Posts: 5848
Re: TListBox and its OnSelectionChange event
« Reply #16 on: September 08, 2023, 03:34:42 pm »
I just checked Delphi, implemented a message capture of the WM_COMMAND+ LBN_SelChange and the operation is exactly the same as the LCL is.

 The LBN_SelChange signal gets sent always no matter, as does the current OnSelectChange.

SO from my point of view, it is working as the LBN_SelChange suggest. The difference is that this event gets a USER check point to separate the difference between software and user operations.
 
 If this works differently on other targets then let it be because what I've seen, they kind of make things work the way they want and not follow windows rules.

 I believe this is more of a Documentation issue and poor choice of wording on the event.

 As for deciding if the selection actually changed, I don't have an issue with that, I merely store the previous ItemIndex and compare it with the new one.



The only true wisdom is knowing you know nothing

Bart

  • Hero Member
  • *****
  • Posts: 5142
    • Bart en Mariska's Webstek
Re: TListBox and its OnSelectionChange event
« Reply #17 on: September 08, 2023, 11:11:55 pm »
Code: Diff  [Select][+][-]
  1. --- win32int.pp 2023-09-07 15:32:19.042377000 -0400
  2. +++ "mod\\win32int.pp"  2023-09-07 15:24:22.802255100 -0400
  3. @@ -298,6 +298,8 @@
  4.    MessageStackDepth: string = '';
  5.  {$endif}
  6.  
  7. +  LastLBSelectedIndex: Integer = -1;
  8. [/quote]
  9.  
  10. How is that going to work if a user has more than 1 TListBox?
  11.  
  12. AFAICS unless we can access FItemIndex (which means a change in LCL, which we aim to avoid for a WS problem), there is no way of knowing what the last known ItemIndex was.
  13.  
  14. Bart

Bart

  • Hero Member
  • *****
  • Posts: 5142
    • Bart en Mariska's Webstek
Re: TListBox and its OnSelectionChange event
« Reply #18 on: September 08, 2023, 11:16:37 pm »
I did not yet check this patch, but does it work in case of multiselection where we need exactly that second click on a previously selected item if the user wants to unselect it. Is this still working?

If ever we add a check for this, this should only be done in single selection mode, because in multi selection mode each click will change what was selected.

Bart

 

TinyPortal © 2005-2018