Ziehen Sie die Ansicht

Ich habe eine NSView dem ich bin hinzufügen, als ein sub-view von anderen NSView. Ich möchte in der Lage zu ziehen die ersten NSView um die übergeordnete Ansicht. Ich habe einige code, der teilweise funktioniert, aber es gibt ein Problem mit der NSView bewegt sich in die entgegengesetzte Richtung auf der Y-Achse von meiner Maus. (d.h. ich ziehen Sie nach unten, es geht nach oben, und die inverse von, dass).

Hier ist mein code:

//-------------------- MOUSE EVENTS ------------------- \\ 

- (BOOL) acceptsFirstMouse:(NSEvent *)e {
    return YES;
}

- (void)mouseDown:(NSEvent *) e { 
    //get the mouse point
    lastDragLocation = [e locationInWindow];
}

- (void)mouseDragged:(NSEvent *)theEvent {
    NSPoint newDragLocation = [theEvent locationInWindow];
    NSPoint thisOrigin = [self frame].origin;
    thisOrigin.x += (-lastDragLocation.x + newDragLocation.x);
    thisOrigin.y += (-lastDragLocation.y + newDragLocation.y);
    [self setFrameOrigin:thisOrigin];
    lastDragLocation = newDragLocation;
}

Wird die Ansicht umgedreht, obwohl ich das geändert, wieder zurück auf den Standard, und es scheint nicht, einen Unterschied zu machen. Was mache ich falsch?

InformationsquelleAutor PruitIgoe | 2011-08-25
Schreibe einen Kommentar