Drag Reordering DesktopListbox

I have a few questions about reordering desktop listbox control (so API 2) using Xojo 2024r4.2.

  1. I have drawn my own disclosure triangles but the checkboxes and the drop indicators do not respect the byref width value set in the paint event. So no matter what width I set the checkboxes are always rendered in same spot. Same with the reorder drop indicators. The depth does not match the updated values. I can move checkboxes to end of the list but looks a little odd. Is there a way to set this value, I tried column alignment offset, but it seemed to have no effect.

  2. In the DragReorderRows Event, if you select too many items from a folder above and drop them into a folder, at the same depth, below the selected items the parent row is incorrect.

So selecting all the files in Sub 1 Folder 1 and dropping them into sub 2 folder 2 the NewPosition is 4 and the Parent Row is 9.
I thought the passed in values are based on all the selected items being removed first then looking at where they need to go. All other drags seem to work just fine.

I might be able to trap it if the parent row is out of bounds or not an expandable row and look at the new position and figure it out from there.

Seems like it has been doing this for a few Xojo versions now, at least 2021r1.1

TLDR;

  1. Can I set where checkboxes are shown in column 0 if I am drawing my own disclosure triangle and passing back width and height for the hit tests.

  2. Can I change the “depth” of a row so it draws reorder drop indicators correctly, based on custom disclosure triangles.

  3. Am I correctly calculating where to put the reordered items, and is dragging more from above to below a Framework bug?

Also how can a parent row be higher than the new position?

Workaround for reorder is if the parent row is >= new position assume wrong and drop 1 above new position

I have a DesktopListbox subclass, and three instances of it. One has checkboxes, and yes, they all line up as in your image - but they are in column 1, not 0. I use the default disclosure triangle.

The drop indicator may change where its head is (i.e. get wider or narrower) depending whether the drop position is ambiguous. You might be wanting to drop as the new last item of an expanded folder, or to drop after the expanded folder. You change what it will do by moving the mouse left or right. I only drag one row at a time.

The row numbers change as rows are expanded/collapsed. When an expanded row is collapsed, Xojo removes the now-hidden rows and all rows after the parent are renumbered so that all row numbers start at zero and increase monotonically. If you expand a row then it’s your job to add the rows and worry about the new row numbers - which will keep changing as you add rows. I also have to update my database which stores the state of all this, so that when the app restarts, the same layout can be re-created.

Getting this to all work nicely was quite some work - I wouldn’t like to have to do it again.

Of the three instances, only one has the checkboxes, and only another allows drag/drop re-ordering. The third doesn’t have either.

this is what custom disclosure triangles does with checkboxes in the first column

You can also see the drag row indicator aligns to checkbox, not where my disclosure triangle is.

The row numbers passed in from the drag reorder event are only references to what is currently shown in the control. Storing the “row number” away makes no sense to me as they are display only values. You can store info in row tag and look up the info from the passed in New Position and Parent Row.

The issue is, in certain cases (dragging from above to below), the parent row is wrong. It is reporting a parent row further down the list than the new position, which is impossible.

It’s been doing this for years.

I put in two Issues about this

Without seeing your code it’s hard to see what is going on. I’ve written my own code to draw the line because I wanted my dragreorder to work like in Xojo: either change the order or move things into folders. The dragreorder thingy looks a bit strange because I can’t draw into 2 cells:

And yes, getting the parent right is complicated.

1 Like

Here are the issues i added, they have simple tests to replicate in them.

https://tracker.xojo.com/xojoinc/xojo/-/issues/78583

https://tracker.xojo.com/xojoinc/xojo/-/issues/78582

I know I could just do my own reordering logic with drag and drop, but would be better to use Xojo’s code.

It is annoying you cannot draw across two columns, but you can draw across two rows. Maybe Xojo’s clipping is wrong. Which is also annoying because you cannot set a clipPath or clipRect in DrawCellText.

Why is that better? I prefer code that works now instead of perhaps in a couple of years. Anything new for the desktop controls is implemented half-baked and without much (if any) quality control.

1 Like

It would be better if it worked. So I am asking them to fix it for us.

1 Like