Talk:NSView
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Why not use something like
- (void) mouseDown: (NSEvent *) theEvent { BOOL isInside; unsigned int mask = NSLeftMouseUpMask | NSLeftMouseDraggedMask; if( nil == target ) return; while( [theEvent type] != NSLeftMouseUp ) { theEvent = [[self window] nextEventMatchingMask: mask]; isInside = [self mouse: [self convertPoint: [theEvent locationInWindow] fromView: nil] inRect: [self bounds]]; switch( [theEvent type] ) { case NSLeftMouseDragged: // drag // // whatever needs to be done while dragging // break; case NSLeftMouseUp: // drop if( isInside ) { // // whatever needs to be done when button is released // } break; default: break; } /*switch */ } /* while */ } /* -mouseDown: */
Looks much cleaner and should be faster.