Disable mouse events on NSSplitView - macos

Could anyone can disable or prevent mouse cursor changed when move mouse to divider of NSSplitView ?
I have a NSWindow with splitView inside, then I try to add a NSView/NSButton to window's contentView to prevent mouse events. What I gain is prevent mouse click, but I need to prevent the mouse cursor changed when I move mouse to splitView's divider below.
So what I try to do is:
Add a view on top to prevent user click on splitView and mouse cursor does not changed.
Like Sparrow app when Ads shown.
Any kind of hint, help, experience is highly appreciated!

On your NSSplitView you could add:
[self addCursorRect:[self bounds] cursor:[NSCursor whateverCursorYouWant]];
Have a look at Apple's sample code DragItemAround

Related

UIScrollView on tvOS

The question is very simple, how to enable scroll and zoom inside a UIScrollView in tvOS?
I tried the same initializer code from iOS and returned the scrollview for the focusedView var, but nothing happens when i touch the remote.
Also, i tried to add another custom UIPanGestureRecognizer to the scrollview and actually it works, but i don't want to handle the pan with custom code, just use the same pan behavior like iOS.
Let me know, thanks.
You can configure the scroll view's built-in pan gesture to recognize touches on the Siri Remote. It doesn't do that automatically, because normally scroll views on tvOS aren't scrolled directly by touches: they're scrolled automatically as focus moves between views within the scroll view.
If you really want the scroll view to move directly from touches, you'll need to add UITouchTypeIndirect to the allowedTouchTypes of the scroll view's panGestureRecognizer:
scrollView.panGestureRecognizer.allowedTouchTypes = #[ #(UITouchTypeIndirect) ];
You'll also need to make sure that either the scroll view itself is the focused view, or is a parent of the focused view, since all touches from the remote will start at the center of the focused view: you need to make sure the scroll view is getting hit-tested for the events to work.
Zooming won't work, because the Siri Remote can only recognize one touch at a time, so you can't do a pinch gesture on it.
Swift 4 version (from here: https://stackoverflow.com/a/41000183/945247)
scrollView.panGestureRecognizer.allowedTouchTypes = [NSNumber(value:UITouchType.indirect.rawValue)]

NSTextField losing Focus/FirstResponder when mouse leaves NSWindow

I have a NSTextField in an NSWindow, when I highlight the text to change it, the highlight is blue. If, while the TextField still has focus, I move my mouse outside of the NSWindow; my NSTextField loses focus and the highlight is now gray. I basically want to keep focus on the NSTextView no matter where the mouse goes, unless they click outside, hit enter, or hit tab. (End Editing)
Has anybody seen this before or know a solution to the problem?
Thanks in Advance
Turns out to be a problem with the outside view having a mouseentered event that would take control of the mouse

How to autoscroll when mouse is near the edge of window

I have an (big) NSImageView embedded in an (smaller) NSScrollView. I want to automatically scroll if the mouse goes near the edge of the window, how do I do this?
You could create an NSTrackingArea to be notified when the mouse enters a particular area of a view and then use one of NSResponder's scroll.. routines to scroll the view.
Cocoa has a built in method called NSView.autoscroll(with:) which will automatically scroll the enclosing scroll view when tracking mouse events and the cursor is outside of the scroll view's clip view.

NSResponder mouseExited when hovering Window title

I have an NSWindow with an NSToolbar and a content view.
I have set the tracking area to be the whole frame of the view.
I wish to have the mouseExited event fired when the cursor leaves the content view and enters the toolbar and/or the window title. What is the best way to achieve this? should I bound the tracking area to just below the toolbar?
The main reason I need this is because my view needs a special cursor. So I'm changing it in mouseEntered and wish to change it again when mouseExited
Thanks
Why not add a cursor rectangle over the entire bounds of the view?

Cocoa - Giving focus to a WebView in an NSStatusItem

I've set the view for my NSStatusItem to a WebView, but I'm not able to capture hover events in the WebView because my NSStatusItem doesn't get focus, like a normal WebView would.
How do I programmatically give my NSStatusItem or its associated view focus so that the embedded WebView will capture mouse events like a normal WebView?
In case anyone cares, one way I can think of is to have the view for the NSStatusItem be a custom NSView that overrides the NSResponder methods mouseEntered:, mouseMoved: and mouseExited:. Then, I would add the WebView as a subview of the custom NSView, and each time the mouse moves inside the NSView, send the coordinates of the mouse to the Javascript in the WebView, which can figure out what element is at the position of the mouse cursor.
Basically, it would be reimplementing mouse hover at its core. Hopefully there's an easier way though.

Resources