Expand tooltip on hover in NSCollectionView not working after ReloadData or tab change - xcode

I have an NSCollectionView inside a Tab which contains subviews with NSTextField that have expanding tooltips.
Strangely, after a new search (ReloadData) or going to a tab and coming back, the tooltips no longer expand. They come back only if I resize the window or scroll the CollectionView*. Clicking in the view does not help. What can I do to automatically have the tooltips work?
*This triggers the CollectionView and the CollectionViewItems to UpdateTrackingAreas. I tried to force this on ReloadData even delayed 1000 ms, but this did not make the tooltips able to expand.
Thoughts:
Something related to UpdateTrackingAreas but not exactly?
Maybe a first responder issue?
It also doesn't work if the window is not the active window (which is ok)
Concerned that it might be related to How do I update the expansion tooltip size after calling NSTextField setStringValue:?

Related

Extra Control inserted into Key View Loop in NSScrollView - Text View in Catalina

The default behavior for an NSScrollView - Text View in Catalina has changed. If the Text View has enough text to show a scroll bar, there is an extra control inserted into the Key View Loop after the NSScrollView has become firstResponder. Mojave does not show this extra control in the Key View Loop.
The 2nd control is a NSScroller contained in the Scroll View. NSScroller as firstResponder doesn't appear to have any functionality (e.g. arrow keys do not have any effect).
Can this behavior be turned off? Is there a way to make the ScrollView have a single responder in Catalina?
One thing I tried is setting "Refuses First Responder" of the NSScroller to false, but this had no effect.
Note: Full Keyboard Access (the Catalina equivalent) must be turned on to reproduce this.
I think the reason NSScroller accepts first responder is so that if all the subviews of your scroll view refuse first responder you still have a way to scroll the scroll view. While the NSScroller is first responder, if I hit page up/page down on my keyboard it scrolls the scroll view. If you want to disable this behavior you can:
scrollView.verticalScroller.refusesFirstResponder = YES;
scrollView.horizontalScroller.refusesFirstResponder = YES;

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.
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

Material-ui-next Popover on GridListTile

Has anyone successfully managed to create a popover on a GridList tile item? From https://material-ui-next.com/demos/grid-list/ I've created an 'advanced' Grid List (horizontally scrolling GridList), but as soon as I try to add popovers, the horizontal styling functionality seems to be discarded, and the popover still does not show (with no errors in console).
It simply doesn't seem to be working. Any ideas?

How to call NSScrollView autoscroll-method programmatically

I have simple chat application with text messages view-based NSTableView as you can see at the picture below.
Each message contains NSTextView instance having height to fit all the text.
All I need is to start NSScrollView (which NSTableView-instance is enclosed by) autoscrolling while the user selecting text dragging mouse far enough. Unfortunately, autoscrolling doesn't appear. In case of dragging somewhere outside of the text views all succeed.
I tried to call autoscroll:-method directly by simply push NSEvent-instance from NSTextView-subclass "mouse dragged"-event (like in example from this article):
- (void)mouseDragged:(NSEvent *)event
{
[self.scrollView autoscroll:event];
}
As I've overrode all the mouse events and implemented all the text selecting, this method often invokes. But the autoscrolling doesn't seem to work.
UPDATE
I figured out that before calling -autoscroll:-method there must be -mouseDown: of the same object. But it breaks my text selecting mechanism. The point even not in being first responder, there must be nothing but the mouseDown:-method.
Normally, a text view is within a scroll view of its own. Even if that's big enough to show all of the text without scrolling, it's still there. A call of -autoscroll: on anything within that scroll view (possibly including that scroll view itself?) will just try to scroll that scroll view, not the scroll view that contains the table view.
Try calling -autoscroll: on a view higher up in the hierarchy. Either self.scrollView.superview, the table cell view, or the table view.
Note, though, that the table view's scroll view will keep scrolling even after the cell view containing the text view is fully on-screen. In fact, it may keep scrolling it so far that it's off the screen in the other direction. Basically, it doesn't know that you're trying to select within the text view so it doesn't know to stop when the selection extends all the way to the edge of the text view.
Another approach might be to try to use a "bare" text view with no enclosing scroll view. I don't think IB will let you do that, so you'd have to do it programmatically. Bare text views don't play well with auto layout, though.

Custom NSCursor is being reset when subviews are added to a view in the window

I'm using NSTrackingArea to define 2 areas in a NSView subclass. Then I'm using mouseEntered/mouseExited to change the cursor to a custom one.
So all works fine when the mouse enters the top tracking area and the custom cursor gets set as expected. All still good when I mouseDown and drag on the top tracking area. But I have another part of the UI that updates when the mouse is dragged and it adds subviews to a view elsewhere on the same window.
As soon as the first subview is added elsewhere, my custom cursor disappears and it reverts back to the arrow cursor. I thought I might be able to force the cursor back to the custom one using cursorUpdate for my view but for some reason it never gets called, even when set as an option in the NSTrackingArea.
Am a bit stumped with this one...
I solved it by overriding cursorUpdate in the window's custom contentView. An empty cursorUpdate method stopped the update from getting passed up the chain and the custom cursor now remains as I've set it.

Resources