Re: Maintaining NSCursor outside of app window
Re: Maintaining NSCursor outside of app window
- Subject: Re: Maintaining NSCursor outside of app window
- From: Quincey Morris <email@hidden>
- Date: Thu, 13 Jan 2011 18:48:15 -0800
On Jan 13, 2011, at 16:48, Markus Spoettl wrote:
> On Jan 13, 2011, at 7:37 PM, Corbin Dunn wrote:
>> - (void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint
>>
>> Then do something like this (after converting the screen point to window coords):
>>
>> NSPoint windowPoint = [[view window] mouseLocationOutsideOfEventStream];
>> NSPoint localPoint = [view convertPoint:windowPoint fromView:nil];
>> if (![view mouse:localPoint inRect:[view visibleRect]]) {
>> [[NSCursor disappearingItemCursor] set];
>> }
>
> Fantastic, thanks so much Corbin!
It may be problem fully solved in regard to your original question, but ...
1. In the past, in trying to debug why the cursor changes back to an arrow unexpectedly (in the sorts of scenario you described) I found that scroll views tend to change the cursor when the pointer passes over parts of the scroll view that aren't showing the document view itself -- scroll bars, borders, etc. That can be annoying when you're trying to manage the cursor very carefully yourself.
2. I don't know how big a problem it is, but there's a doubtful aspect of using 'mouseLocationOutsideOfEventStream' like this. At the time such code is executed, the position of whatever is being dragged (the transparent image in this case) may well be synchronized with the event stream. It's possible for the unsynchronized position to be quite different, which means that the image position and the cursor shape would end up being puzzlingly mismatched.
Whether this would afflict the above code, I really don't know, but it's worth spending a bit of time testing (with fast pointer movements and busy processors, perhaps).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden