Strange listbox cellcheck behavior

I have a report from a user about one of my MAS apps that has me stumped. There is a single listbox in the main window that accepts multiple selections and handles option-clicks for checkboxes in the CellAction event. The user has sent a screen capture of strange behavior when trying to toggle the checkboxes in the listbox. I have been unable to reproduce this behavior and everything looks normal on test computers. In addition to the weird checkbox behavior, some of the user’s listbox column headings are incorrect.

Here’s the normal listbox behavior on my computer and the others Macs I have tested the app on:
https://edittoolsspace.nyc3.digitaloceanspaces.com/Xojo/MyListBox_1.mp4

And here’s the movie from the end user of the odd listbox behavior:
https://edittoolsspace.nyc3.digitaloceanspaces.com/Xojo/UserListBox_1.mov

Here’s a screen cap of my Main Window of the listbox with correct headings:
https://edittoolsspace.nyc3.digitaloceanspaces.com/Xojo/MyMainWindow1.jpg

And the user’s screen cap of the listbox with incomplete headings:
https://edittoolsspace.nyc3.digitaloceanspaces.com/Xojo/UserMainWindow1.mov

Here’s the code I have in the ListBox.CellAction event:

Dim selectedRows() As Integer // Will hold the index of each selected row
dim checked as Boolean

// handle option-click of checkbox
if column = 0 then
  If Keyboard.OptionKey Then
    for i as integer = 0 to me.LastRowIndex
      me.CellCheckBoxValueAt(i, 0) = not me.CellCheckBoxValueAt(i, 0) 'toggle all checkbox values
    next
    me.CellCheckBoxValueAt(row, column) = not me.CellCheckBoxValueAt(row, column) 'toggle the checkbox value of the clicked row
  end if
end if
//

// is the media online? if not, don't allow the checkbox to be checked
if me.Cell(row, 7) = kListHeadMediaNotFound then
  me.CellCheck(row, column) = False
else
  // handle multiple row checking and unchecking
  if me.SelCount > 1 then
    For i as integer = 0 To ListBox1.ListCount - 1 // Rows are zero-based
      If ListBox1.Selected(i) Then
        selectedRows.Append(i) // This row is selected
      End If
    Next
    // is the click on a selected row?
    for i as integer = 0 to UBound(selectedRows)
      if row = selectedRows(i) then
        // is the row checked or unchecked?
        if me.CellState(row, 0) = Checkbox.CheckedStates.Unchecked then
          checked = true
        ElseIf me.CellState(row, 0) = Checkbox.CheckedStates.Checked then
          checked = false
        end if
        // set the checkbox on the selected rows
        for j as integer = 0 to UBound(selectedRows)
          if checked = true then
            me.CellState(selectedRows(j), 0) = Checkbox.CheckedStates.Unchecked
          elseif checked = false then
            me.CellState(selectedRows(j), 0) = Checkbox.CheckedStates.Checked
          end if
        next
      end if
    next
  end if
end if

I have a vague memory of this kind of listbox behavior in a couple of beta builds for another app several years ago, but I haven’t seen it since.

Many thanks for any ideas or suggestions?

If this statement is encountered, it would explain the behaviour.

@Arnaud_N
Thanks for your reply. I’m having trouble seeing how the code would cause the behavior in the user’s screen capture. The line is intended to prevent the checkbox from being checked in rows that represent offline/unfound media files. So, if the text “Media Offline” is found in column 7 make sure the checkbox remains unchecked. Maybe there’s a better way to do this.
The odd checkbox and the heading issue make me think there’s something going on with the listbox control.

Well, I have no idea how you look for the medias. Should the 7th column be filled by something when all is correct? (in the video, the column is blank; perhaps the constants are also blank for his app’s installation?)

Can you debug with the user (that is, make custom builds to try with him)? You may make a custom version where you log each “if” evaluations (e.g. with showing a MessageBox) and see the problem there.

I also quite not understand why you toggle every row and then toggle the clicked one again. Can’t you just return true after the loop to prevent the toggle?

@Arnaud_N
I think you’re on to a big reason this code isn’t working right for this user. All rows should either have “Media Online” or “Media not found” in Column 7. I need to dig around and find out why Col 7 is blank in his case. You might have noticed his media is stored on a Google Drive. I don’t know how OS X handles them but it’s curious that it coincides with the first report of this problem.
The purpose of the code in this event is three-fold. #1 ignore rows that represent offline media and be sure they are not checked. #2 handle option-click by toggling all checkboxes. #3 handle a checkbox click on a selected row by toggling the checkboxes on all the selected rows.
I wrote this code a while ago and need to revisit and improve/correct it. I appreciate and agree with your suggestion for the option-click code. I’ll work on rewriting it.
Thanks for pointing out some of the problems.

You might want to check why the user has all media both on and offline - see the status lines above the listbox.