I am banging my head against the wall on this one. I think the ParentRow that is being returned by the framework is wrong.
The documentation says:
I’ve logged this at <https://xojo.com/issue/44383>
In my example project (attached to the report) it is saying the ParentRow as 2 when I feel it should be 3. Am I wrong about this?
Drag reorder of a hierarchical listbox is freaking insane! Has anyone done this that can share an example?
I did it a long awhile ago… IIRC (and I may not be) the confusion is that the positions you get is what it would be AFTER the the move… so the what position you get depends on if the row you are dragging comes from before or after the new parent… Easy to check
You are recalling that correctly, I just tested it.
hm…okay. Documentation is pretty awful in its description then.
Thanks! That will help.
The Styledline code on my website should have an example in the PalletBuilderWin , but there is a lot of other stuff going on there too.
[quote=274246:@Karen Atkocius]I did it a long awhile ago… IIRC (and I may not be) the confusion is that the positions you get is what it would be AFTER the the move… so the what position you get depends on if the row you are dragging comes from before or after the new parent… Easy to check
Fwiw, that’s the only way you’d have a chance in heck to know for sure where the user dropped the item. You should be able to use the ListIndex for removing the item and the position for Inserting it.
Well, I argue that since you know the state of the listbox before the event occurs, and the listbox does zero work for you, it should give you the ParentRow from the same initial state NOT the parentRow index AFTER the reorder.
I wish I had take the time during the initial beta period to do this. I’m sure I would have commented on it at the time time. But since it’s official canon now I’ll just have to move on and figure it out.
Not sure how this would be a beta issue ?
The listbox has behaved like this, as far as dragging hierarchical rows, for about as long as it has supported hierarchical lists
If it didn’t tell you the destination row how would you know where to put it ?
Now it MIGHT tell you the source (what rows were being dragged) & destination, but that doesn’t work well with multiple rows being dragged. You’d need an array of listindexes as the “source” parameter since it could be one or more rows being dragged.
But that’s exactly what the listindex &/or selected property tells you - what row(s) were being dragged.
This way you have both the source and the destination (which is only one row since you cant drop them in more than one spot)
Not THIS beta cycle. ParentRow, if I recall correctly, was added in the recent past.
Sure, it tells you the destination row, but it adjusts the index. Not what it was at the beginning of the drag, but it will be after the drag. It seems incongruent with the nature of us having to do all the work in the hierarchical listbox reorder. The event was clearly made for the standard listbox but the addition of the parentRow, IMO, is wrong if you’re making us do all the work.
As I said, it’s already there and already implemented so I’ll make do. The documentation is awful in explaining what it does and AFAIK there are no good examples of how it’s supposed to work in the real work. I’ve spent some good brain power on this one issue (which obviously isn’t much).
It’s been there at least 10 years
I have one question about the parentRow and newPosition, why are these positions of the reorderdrag in a hierarchal list not in sync with it’s data when shown in the debugger?
For example if you reorderdrag to an position greater then then originposition you have to add one to get the correct data from the row. The debugger lists still the total amount of rows?
Also the parentRow is complete wrong according the debugger list information.
If the newPsition is the position you should have after the drag, because the old row pulled out of the cache / stack then the debugger should not shown this…
Correct or wrong?
There are some oddities with Hierarchical drag reorder that don’t make sense.
<https://xojo.com/issue/44383> for example, parentRow is returning incorrect index for parent.
File feedback reports with example projects and details on how to reproduce. That’s the only way they’ll get fixed. And even then it might take a while.
That is the same issue i have, drag below and you need to add one position for the newPosition, drag one in the opposite way and every thing is fine. Expect for the parent row.
Also the y-value on the mouse down to determine where the insertion row is looks a little bit odd.
Half way of each adjacent row.
Than raise the question is the insertion below the line or above the line ?
My work-around is to add one row for the newPosition and of course store dragRowIndex by starting of the drag and calculate the parent row with an small function. the parent is always one level higher (depth is lower).
If me.dragRowIndex <= newPosition Then
newPosition = newPosition +1
GetParentIndex(Index as Integer):
Dim parentIndex As Integer = -1
For i As Integer = index DownTo 0
If me.RowDepth(i) < me.RowDepth(index) Then
parentIndex = i
The one good thing is that it’s consistent and you can work around it.
Though it will absolutely drive you bonkers trying to figure it out.
Yes Complete, But there is one place that is telling you what’s happening with your list… the debugger Variables; your instance of the list and then the contents. Instant information and correct!
One Correction: the parentRow seams to be correct, if the row is folder then you can shift the insertion dot to the left - right to get the correct parent, but this does not function on the first row, then te insertion dot is then always to the left, and the parent row always the row above. I took a few drinks to figure this out?
I think I spent a week trying to figure it out.
Do you known if there is a way to get the information of the parent row and newpostion while the user drag over the list.
It should be somewhere, otherwise the list could not act with the movements of the insertion icon-dot. I want to use it to block and / or inform the user that some drag reorder is allowed.
Sorry, it’s been too long since I’ve worked with it. My suggestion is to have the most minimal project you can get to work out those details.