Desktop app ListBox not firing CellClick event when clicked

What could cause a ListBox in a desktop app to not fire its CellClick or Change events when clicked on?

I’m trying to track down an obscure bug in my desktop app where a couple of macOS users (out of an install base of many thousands) are reporting that clicks on three essential navigation controls are not working. The three controls are all subclasses of ListBox.

I ended up adding extra logging in the ListBox.CellClick and ListBox.Change event handlers of all three controls and they’re not being fired when clicked on. Using the arrow keys does trigger the ListBox.Change event for them.

One of the ListBox instances does not have a ListBox.MouseDown event handler, so I don’t think that this can be caused by returning True from ListBox.MouseDown. The other two instances do have ListBox.MouseDown handlers and they are firing, so I’m going to add extra logging to them to work out if any of the circumstances that cause it them return True could be firing.

Any ideas?

i would log all ListBox events and your return state if this event was handled.
use CurrentMethodName for the log

A few versions of macOS ago, and a few versions of Xojo ago, there was a bug where if you attempted to drag from within a listbox, and your code attempted to add multiple drag images to the DragItem, it would crash, silently, which was really weird as it just sort of did nothing.

This was hard to debug as it only happened:

  • with more than one row selected
  • when dragging (but not clicking, unless the click moved more than a few pixels, in which case it was actually a drag event).

Any chance this could be happening to you?

Edit: it’s this crash: NSGenericException when dragging from one listbox to another
Feedback: <https://xojo.com/issue/63255>

i would log all ListBox events and your return state if this event was handled.
use CurrentMethodName for the log

Thanks, Markus: I’m already doing that for some event handlers but am adding more and waiting for the affected users to install the update.

That’s an odd one Mike, but I don’t think it explains what’s happening here with Xojo 2022.1. What’s really puzzling me is that it’s only affecting a couple of users, one using macOS 12, the other using macOS 10.15.

Could they be using unusual input devices, such as non Apple mouse or trackpad ?

Yes, both have the Wacom tablet drivers installed, but the bug occurs when using an Apple trackpad too. And I’m not sure how the Wacom drivers would prevent clicks registering on the affected ListBox controls while other ListBox controls in the app are fine :man_shrugging:

Does the listbox highlight the clicked row(s) anyway, or not at all? Any visual thing happening?

Nope, the selected row does not change when clicked on. The up and down arrow keys do change the selection after it’s been clicked on, though.

I’m waiting to hear back from the affected users now that I’ve added extra logging to the MouseDown events on the affected ListBox controls, I’ll report back if I learn anything.

Fwiw, if anyone wants to see the effect in person, this bug presents in the Lifeboat Server Tools listbox.

Yeah, that would be the next step, is the Listbox receiving mouse down events, and are they where you would expect them to be…

If the listbox receives the mouseDown event, but the co-ordinates are wrong, then this might be the same issue that prevents listboxes from working correctly on a NSPopover. In which case I can provide a hacky solution for handling mouse down at least.

1 Like

I just tried, out of curiosity. However, I could click on any row just fine.

And I am now seeing it on 1 of 4 listboxes present on a main window’s panel. All four had the same events defined, but the problem listbox never fires the CellClick event on Windows - it works on Linux and macOS. My code is never touched:

If Not IsContextualClick Then
  Try
    Select Case Me.RowTag(row)
    Case RowType.OperationTop
      Return True // fake header row, so ignore
    Case Else
      Return False // let the listbox highlight the row
    End Select
  Catch NilObjectException // never occurs
    Return True // ignore the exception
  End Try
Else
  Return False // let the ContextualClick handler do its thing
End If

The same code works on the other 3 listboxes and in this listbox on macOS and Linux.

Wow! Let’s hope they can get it fixed and sent out to the world ASAP. Lightwright is full of listboxes that use CellClick events.

Confused. Is this Windows or Mac bug?

I don’t think it’s platform specific, though the results don’t seem to be consistent.

1 Like

Windows for me, macOS for Tim P …

Is this failure new in 2022 R1.1?

I haven’t had any users report listbox click issues when built with 2021, but Lightwright uses listbox clicks in probably 200 places, so the odds of it happening somewhere when built with 2022 R1.1 are scary.

I’m already logging a lot of listbox click events, but it’s the absence of those events that needs catching, not sure how to detect when there’s a problem.

Thoughts?

That’s what we’re seeing as well - an absence or the event. It’s almost as if the ListBox is disabled (it’s not) and completely ignoring the CellClick and MouseDown/Up.

Is this with the Listbox or the New Listbox?