Giles
Giles

Reputation: 1668

Make sure NSTrackingArea refreshed in Nested NSScrollViews

I have an NSCollectionView in an NSScrollView. The scroll view scrolls horizontally to move along the line of items. Inside each each collection item is a vertically scrolling NSOutlineView.

I have NSButton objects for opening and closing collection items - as supplementary views in my collection. I set up NSTrackingAreas on these buttons to support mouse over effects.

This works correctly, until I scroll, at which point the NSTrackingArea areas are clearly left behind (the mouse over effects happen when the mouse is where the button was, not where it is).

I rebuild my tracking areas in updateTrackingAreas in my button class, and this is called, but not often enough.

I have tried using .inVisibleRect when setting up my tracking areas, rather than explicitly rebuilding them, but that doesn't improve the tracking update.

I have tried calling updateTrackingAreas on the NSCollectionView when scroll occurs, but it is never passed down to the child views as I expected it would.

As a side note, I also have NSTextViews in my collection view items with toolTips that are very flakey too. They are often left hanging. Pointing hand cursors over links are often misaligned.

It feels as though the default updateTrackingArea is over-optimised and is not being called as often as it should.

So, I am about to embark on building my own tracking-area-tracker to register and update my views when they are not updated by default...

...but maybe someone can see something obvious that I am missing? Thank you.

Upvotes: 0

Views: 449

Answers (1)

Giles
Giles

Reputation: 1668

The tracking area setup can be subtly broken when nesting scroll views incorrectly. See the answers regarding nesting scroll views here for details:

NSScrollView inside another NSScrollView

Upvotes: 0

Related Questions