다른 NSView의 하위보기로 추가 할 NSView가 있습니다. 상위 뷰를 중심으로 첫 번째 NSView를 드래그 할 수 있기를 원합니다. 부분적으로 작동하는 일부 코드가 있지만 NSView가 내 마우스 끌기에서 Y 축의 반대 방향으로 이동하는 문제가 있습니다. (즉, 아래로 드래그하면 위로 올라가고 그 반대가됩니다). 내가 그 다시 기본값으로 변경하고 변화를 보이지 않았지만,NSView :보기 드래그
// -------------------- 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;
}
보기가 뒤집어 :
여기 내 코드입니다. 내가 도대체 뭘 잘못하고있는 겁니까?