ftp.nice.ch/pub/next/developer/objc/appkit/DragDemo.1.1.s.tar.gz#/DragDemo_1.1/MouseView.m

This is MouseView.m in view mode; [Download] [Up]

/*
 *	MouseView --  John Glover, adapted from MouseTracker by Randy Nelson
 *	An abstract class that manages a modal loop for tracking the mouse
 *
 */

#import "MouseView.h"

@implementation MouseView



- setTrackingRect:sender
{
    NXRect myFrame = frame;
    [[self superview] convertRect:&myFrame toView:nil];
    [window setTrackingRect:&myFrame
	    inside:NO
	    owner:self
	    tag:23
	    left:NO
	    right:NO];
    return self;
}

- mouseDown:(NXEvent *)e
 {
    NXPoint startPoint = e->location, nextPoint;
    int looping = YES;
    int oldMask = [window addToEventMask:NX_MOUSEDRAGGEDMASK];
    
    /* do first mouse down action */
    [self convertPoint:&startPoint fromView:nil];
    [self mouseDownAction:&startPoint];
    
    while (looping){
	e = [NXApp getNextEvent:NX_MOUSEUPMASK|NX_MOUSEDRAGGEDMASK];
	nextPoint = e->location;
	[self convertPoint:&nextPoint fromView:nil];
	if(e->type == NX_MOUSEDRAGGED){
	    [superview autoscroll:e];

	    /* do continuing mouse dragged action */
	    [self mouseDraggedAction:&nextPoint];
	}
	else{
	    looping = NO;

	    /* do mouse up action */
	    [self mouseUpAction:&nextPoint];
	}	
    }
    [window setEventMask:oldMask];
    return self;
 }
 
- mouseEntered:(NXEvent *)e
{
    return [super mouseEntered:e];
}

- mouseExited:(NXEvent *)e
{
    return [super mouseExited:e];
}

- mouseDownAction:(NXPoint *)currentLocation
{	
    return self;
}

- mouseDraggedAction:(NXPoint *)currentLocation
{
    return self;
}

- mouseUpAction:(NXPoint *)currentLocation
{
    return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.