I have a fairly complex listbox which has the Allow Expandable Rows property set.
When the disclosure triangle is clicked a variable number of rows should be created for the row being expanded.
The expansion is only 1 level deep.
My problem is when I click the triangle ExpandRow is not being called, the Change event is.
At this point Change causes the program to fail.
If I disable the change event and run the program and click the triangle the row remains selected, click it again and the ExpandRow event runs fine.
The documentation uses DoubleClick to toggle the expanded status, but it doesn’t cure the problem either.
I don’t understand why the Change event is being called. Anyone got any ideas?
The File Browser example works fine (load an example, Files, File Browser).
Can you try it ?
Yes I know, I tried it and I wrote a simple program that created and loaded a hierarchical listbox and
its Expand / Collapse events worked fine. What I can’t figure out is why the Change event is running
instead of the ExpandRow.
It’s likely just running before, and your code needs to be refactored to defend against invalid selections. Work out the error in the Change event. You haven’t told us what it is, but I bet it’s fixable and the actual root of the problem.
The change event is running and as a result it is calling a method that tries to access a table that doesn’t yet exist, hence a NilObjectException. I still have an earlier version of the program that uses API v1 and it works fine, even if I compile that in Xojo 2019v3. In that version clicking the disclosure triangle calls the ExpandRow event and doesn’t go near Change. I don’t think it’s an API problem.
And I’m absolutely sure it’s my problem, I just can’t figure out why the Change event is running so I don’t really know where to look.
If you found a different behavior between the classic API and API 2.0 you should file that as a bug report!
Do you have any code in cellClick that might cause change to fire?
Thanks for that. I’m quite sure I’m doing something wrong, I’ve no idea what or where to start looking. I created this section of the app by cutting and pasting from an older version and converted to API2.0. I’ll rewrite it from scratch and if the behaviour reappears in the new version I’ll report it.