Created
January 7, 2012 13:05
-
-
Save Dimillian/1574706 to your computer and use it in GitHub Desktop.
Drag and drop, first working attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)moveToLocation:(NSPoint)location withInitialMousePosition:(NSPoint)position | |
{ | |
isDragging = YES; | |
windowContentView = [[self window]contentView]; | |
if (isDragging) { | |
//down | |
if (previousMousePosition.y > location.y) { | |
float current = position.y - location.y; | |
swapForce = round(current/drop_height); | |
if (swapForce != 0 && swapForce != previousSwapForce) { | |
[delegate swapDown:self]; | |
} | |
} | |
//up | |
else{ | |
float current = location.y - position.y; | |
swapForce = round(current/drop_height); | |
if (swapForce != 0 && swapForce != previousSwapForce) { | |
[delegate swapUp:self]; | |
} | |
} | |
(location.x > 85) ? [self setHideAfterDragginOperation:YES] : [self setHideAfterDragginOperation:NO]; | |
} | |
[self setFrameOrigin:NSMakePoint(location.x - mouse_in_icon, location.y-mouse_in_icon)]; | |
[windowContentView addSubview:self]; | |
previousSwapForce = swapForce; | |
previousMousePosition = location; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment