Listbox scroll bar oddity

Like probably most people these days, I tend to scroll listboxes by using the mousewheel. That is, it’s rare to have the mouse pointer enter the scrollbar. Today I noticed something odd when mousing over the scrollbar under macOS Sonoma - there were some unexpected visual effects. Investigating this, I quickly pinned it down to the PaintCellText event.

Ordinarily, this event fires row by row and column by column - all columns for the first row from 0 to n, then the same for subsequent rows. However, when I moved the mouse over the scrollbar (no mousedown), the event didn’t fire for columns 0 and 1, but did for the following columns. It was easy enough to fix, but why should the PaintCellText event be firing anyway, if the mouse is over the scrollbar?

Under Linux and Win-10, the visual effects did not occur, meaning that either the event does not fire when the mouse is over the scrollbar, or it fires for all columns.

This was with 2023R4.

Screenshot? Code? I’ve never seen visual artifacts over a scrollbar in macOS.

The artefacts were within the listbox itself, were related to text decoration, and were entirely explicable once I found that PaintCellText events were happening with the mouse in the scrollbar, but were not firing for all columns. So it was easy to fix.

Columns 0 and 1 are only different from the others in that they contain images rather than text.

May be related to the “Show scrollbars” settings (System settings→Appearance→Show scrollbars), making the OS decide when to show or hide the scrollbar (thus needing a refresh that possibly Xojo doesn’t handle well)? :man_shrugging:

Have you tried to swap these to see if the result is the other way around?

No. When I get a bit more time I may try a small test and possibly submit an Issue.

1 Like

It’s possible that the scrollbar is subtly translucent in newer versions of macOS and the OS is raising the event because it could require a redraw.

Testing appears to indicate that under Win-10 and Linux, moving the mouse over the scrollbar doesn’t cause the paint event to fire unless one actually presses the mouse button and moves the scroller. The translucency suggestion of @Greg_O is a good one.

Meanwhile I think the reason that I don’t get the event for my app’s columns 0 and 1 might be because in the ordinary course of events I never write any text in those columns. OTOH, if I just scroll with the mousewheel, I get events for all columns (including 0 and 1), so there’s a lack of consistency there.

Writing a space into those columns as well as the image causes the event to fire in the spacebar for those columns too, but I think I’m going to leave things as they now are.