Skip to content

Commit

Permalink
Synchronizing widget moves
Browse files Browse the repository at this point in the history
  • Loading branch information
Saikat Chakrabarti committed Apr 22, 2010
1 parent e2980fb commit d50071a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client/AppController.j
Expand Up @@ -31,6 +31,15 @@
if (!data.action)
return;

if (data.action === 'move')
{
var widgetToMove = [canvas widgetByJSObject:{'type' : data.widget.type,
'frame' : CGRectMake(data.startOrigin.x,
data.startOrigin.y,
data.widget.frame.size.width,
data.widget.frame.size.height)}];
[widgetToMove setFrameOrigin:data.widget.frame.origin];
}
if (data.action === 'fetch')
{
[[SCSocket sharedSocket] sendMessage:[canvas toJSON]];
Expand Down
8 changes: 8 additions & 0 deletions client/Widget.j
Expand Up @@ -54,6 +54,14 @@
[self setFrameOrigin:newOrigin];
}

- (void)mouseUp:(CPEvent)anEvent
{
if (!CGPointEqualToPoint(startingOrigin, [self frame].origin))
[[SCSocket sharedSocket] sendMessage:{'action' : 'move',
'widget' : [self toJSON],
'startOrigin' : startingOrigin}];
}

- (JSObject)toJSON
{
return {'type' : CPStringFromClass([self class]),
Expand Down

0 comments on commit d50071a

Please sign in to comment.