In 2024r1.1 if i have a listbox with checkboxes in column 0 it is impossible to have it select mulitple rows and toggle the checkbox. The selection is cleared and set to the row you are clicking.
I am wanting to add some code to set the checkboxes for all the selected rows to be the same. The mousedown starts the drag to select rows events, before the checkbox fires.
In theory i could find the rows selected at mouse down, and reset the selection after getting the cellAction event, though this seems a little backwards.
You have to do it yourself.
The first thing you should decide is whether the user attempted to check all the checkboxes or just made an ordinary click (the user may just want the behaviour you currently get, to select a single checkbox).
Once you know you want to check every checkbox of the selected rows, you can put this code in the CellPressed event:
for i as Integer=0 to me.LastRowIndex
if me.RowSelectedAt(i) then me.CellCheckBoxValueAt(i,0)=True
next
Return True
Next, you might want to determine if your user wants to uncheck all the checkboxes. Don’t get trapped in a custom design; imagine your users may need more than you think.
I personally like the Apple way, e.g. in Music: command-clicking on a checkbox will check/uncheck all checkboxes in a given list. However, I don’t see a direct relation between selected rows and checkboxes; not sure your design is intuitive.
What I have done for years is allow the user the multiple select rows and toggle a checkbox. All selected rows get that checkboxes value. If they check a box outside of the selection only that one is toggled. Works well and allows users to quickly and easily check lots of boxes.
In this new version of xojo the checkbox is not consuming the mouse down event so while the box toggles its state the mouse drag to select rows also occurs, which in turn updates the selection before the cell action is fired.
I have tried consuming the mouse down event myself but have odd results with the checkbox toggling.
I have not tried in cell pressed yet, but the listbox has changed since 2023r4.1 in this area.
If the behavior has changed you may want to create a sample project, write the steps to reproduce and the difference between older version and new version. Please post that to Issues.
I made a test app in 2023r4 and 2024r1.1 with a Listbox and a desktoplistbox and there is a define change in 2024r1.1 with the desktop listbox. I’ll add to issues
Looks like I could workaround with cell pressed and returning true on the checkbox columns
I have not been keeping up with recent versions and am using API 1, but that would certainly break a lot of my existing listbox code if I applied it to API 2…
I hope that change is well documented in the release notes as well as the listbox docs … and that it was intentional … If not intensional it would be a bug IMO!