Re: Point under a scroller?
Re: Point under a scroller?
- Subject: Re: Point under a scroller?
- From: Mark Dawson <email@hidden>
- Date: Tue, 1 Mar 2005 12:17:58 -0800
This mostly seems to work now. It turns out that I misunderstood the view hierarchy--the enclosing view of a scroller is NOT the sub view of the scroller--there's a clipview in between. That actually makes things easier--all I do now is detect when I get close to the edge of the clipView. I'm also trying to get the scroll region to update when my object (not just the cursor) gets into the edge of the clip view, as I think that seems (to me) to be a better UI solution.
NSView *superView = [self superview]; // this gets the scroller's clip view
NSRect clipRect = [self convertRect: [superView bounds] fromView:superView];
NSRect noAutoScrollRegion = NSInsetRect(clipRect, 4, 4); // 4 pixel band for auto scroll region
NSRect selObjRect; // rect encompasing all selected objects
...
// first check if should auto scroll
if (!NSContainsRect(noAutoScrollRegion, selObjRect))
[superView autoscroll:theEvent];
On Mar 1, 2005, at 9:00 AM, Mark Dawson wrote:
It seems to me that to implement an autoscrolling region for an existing view that may be bigger than its NSScroller view, I want to track when I'm "under" the scrollers; if so, then send the autoscroll: message. However, to do this, I need to figure out when I'm under the scrollers.
If I have a subview of a scroller, how do I determine whether or not a point in that subview is under the scrollbar or scroll arrows?
Is the below the correct way to get the scroller rect?
<x-tad-bigger>// convert scroller to local coordinates
</x-tad-bigger>NSScroller *superView = [self superview]; // Should I cast this? (NSScroller *)[self superview]?
NSRect scrollerRect = [self convertRect: [superView rectForPart:NSAllScrollerParts] fromView:superView];
<x-tad-bigger>
Would I then use [self mouse:point inRect:</x-tad-bigger> scrollerRect], even if I'm not using the mouse cursor? Where "point" would be the right-most point of the item I'm scrolling (for the vertical scrollers)--I think it makes more sense to instigate an auto scroll when the piece I'm dragging enters the "autoscroll" region, rather than the cursor itself. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden