function touchStart(event) {
touchStartingPointX = event.touches[0].pageX;
touchStartingPointY = event.touches[0].pageY;
}
function touchMove(event) {
var deltaX = event.touches[0].pageX - touchStartingPointX;
var deltaY = event.touches[0].pageY - touchStartingPointY;
[verticalScrollView moveByOffset:CGSizeMake(deltaX, deltaY)];
[horizontalScrollView moveByOffset:CGSizeMake(deltaX, deltaY)];
touchStartingPointX = event.touches[0].pageX;
touchStartingPointY = event.touches[0].pageY;
}
@implementation AppController : CPObject
{
float id touchStartingPointX;
float id touchStartingPointY;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
touchStartingPointX = 0.0;
touchStartingPointY = 0.0;
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask];
[theWindow setAcceptsMouseMovedEvents:YES]
[theWindow setAutorecalculatesKeyViewLoop:YES];
windowContentView = [theWindow contentView];
[windowContentView setBackgroundColor:KKRoAContentViewBackground];
[windowContentView setPostsFrameChangedNotifications:YES];
var element = windowContentView._DOMElement;
element.addEventListener("touchstart", touchStart, false);
element.addEventListener("touchmove", touchMove, false);
verticalScrollView = [[CPScrollView alloc] initWithFrame:[windowContentView frame]];
[verticalScrollView setHasVerticalScroller:YES];
[verticalScrollView setHasHorizontalScroller:NO];
[verticalScrollView setAutohidesScrollers:NO];
[verticalScrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
verticalContentView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, [windowContentView frame].size.width, 1060.0)];
[verticalContentView setAutoresizingMask:CPViewWidthSizable | CPViewMaxYMargin];
[verticalContentView setBackgroundColor:[CPColor greenColor]];
[verticalScrollView setDocumentView:verticalContentView];
horizontalScrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0.0, KKRoAY0, [windowContentView frame].size.width, [verticalContentView frame].size.height - KKRoAY0- KKRoAY2)];
[horizontalScrollView setHasVerticalScroller:NO];
[horizontalScrollView setHasHorizontalScroller:YES];
[horizontalScrollView setBackgroundColor:[CPColor redColor]];
[horizontalScrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
contentView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 1800.0, [horizontalScrollView frame].size.height)];
[contentView setAutoresizingMask:CPViewWidthSizable | CPViewMaxYMargin];
[horizontalScrollView setDocumentView:contentView];
[windowContentView addSubview:verticalScrollView];
[verticalContentView addSubview:horizontalScrollView];
--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at http://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/groups/opt_out.
function touchMove(event)
{
var deltaX = event.touches[0].pageX - touchStartingPointX;
var deltaY = event.touches[0].pageY - touchStartingPointY;
if ( Math.abs(deltaX) > 5.0 || Math.abs(deltaY) > 5.0)
{
[verticalScrollView moveByOffset:CGSizeMake(0.0, deltaY)];
[horizontalScrollView moveByOffset:CGSizeMake(deltaX, 0.0)];
touchStartingPointX = event.touches[0].pageX;
touchStartingPointY = event.touches[0].pageY;
event.stopPropagation();
}
}
-(BOOL)collectionView:(CPCollectionView )aCollectionView canDragItemsAtIndexes:(CPIndexSet )indexes withEvent:(CPEvent)anEvent
{
return NO;
}
in the CPCollectionView delegate.
Regards. Bruno
function touchMove(event)
{
[verticalScrollView flashScrollers];
[horizontalScrollView flashScrollers];
...
}
having previously defined:
[verticalScrollView setScrollerStyle:CPScrollerStyleOverlay];
[horizontalScrollView setScrollerStyle:CPScrollerStyleOverlay];
Regards. Bruno.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.