How to autoscroll when mouse is near the edge of window - cocoa

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.

Related

Disable mouse events on NSSplitView

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

Cursor over NSView placed over NSTextField

I have a semi-transparent NSView subclass that acts as a kind of tooltip. When the tooltip is drawn on the screen it draws on top of a form and so it covers a couple of NSTextField's.
When I hover the mouse over the tooltip at the spots where a NSTextField exists, the cursor changes to the input style cursor.
How can I prevent the cursor from changing?
Overlapping views are not really supported very well in Cocoa and the behaviour is undefined.
Instead, your tooltip view should be in its own borderless window, large enough to contain your view. The tooltip window should be a child window of the main window it's attached to. To make a window a child of another window, you use the addChildWindow:ordered: method of NSWindow.
Child windows are attached to the parent window and will move with their parent window when the parent window moves. If you just open a new window without making it a child window, it will be "left behind" if the other window is moved.
To make a borderless window, pass NSBorderlessWindowMask as the styleMask to the initWithContentRect:styleMask:backing:defer: method of NSWindow.

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?

How to write an own resize corner/handle for an NSWindow?

How can I write an own resize corner/handle for an NSWindow? I'm using a subclass of an NSWindow without the default resize corner, but I need it for my window.
The basic outline:
Create a view.
Put some "drag me" indicator appropriate to your window in the view.
Have the view's drag action method respond by resizing the window so that the corner in question is now located at the current mouse position.

Can I have resizable by mouse views with Cappuccino?

Can I have resizable by mouse views with Cappuccino ?
I mean, I need a "iTunes" layout as the layout sample code on their website.
But I wold like to be able to resize the areas with the mouse from the browser in order to customize the UI.
Can I make it ?
You can use a CPSplitView to put two mouse resizable views side by side. The divider between them can then be clicked and dragged with the mouse to reallocate space between the two views. This is the equivalent of Cocoa's NSSplitView.

Resources