Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed touch events on Mac OS X 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 2, 2010
1 parent e808edd commit 2dab4e6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -57,11 +57,13 @@ - (void)listen:(SDL_WindowData *)data
} else {
[_data->nswindow setDelegate:self];
}
// FIXME: Why doesn't this work?
// [center addObserver:self selector:@selector(rightMouseDown:) name:[NSString stringWithCString:"rightMouseDown" encoding:NSUTF8StringEncoding] object:[_data->nswindow contentView]];
[center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp];
[center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp];

[_data->nswindow setAcceptsMouseMovedEvents:YES];
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[[_data->nswindow contentView] setAcceptsTouchEvents:YES];
#endif
}
Expand Down Expand Up @@ -295,7 +297,7 @@ - (void)touchesCancelledWithEvent:(NSEvent *) theEvent

- (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event
{
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
NSSet *touches = 0;
NSEnumerator *enumerator;
NSTouch *touch;
Expand Down Expand Up @@ -357,7 +359,7 @@ - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event

touch = (NSTouch*)[enumerator nextObject];
}
#endif /* MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 */
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 */
}

@end
Expand Down Expand Up @@ -437,6 +439,9 @@ - (void)rightMouseDown:(NSEvent *)theEvent
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
NSView *contentView = [[SDLView alloc] initWithFrame: rect
listener: data->listener];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
[contentView setAcceptsTouchEvents:YES];
#endif
[nswindow setContentView: contentView];
[contentView release];

Expand Down

0 comments on commit 2dab4e6

Please sign in to comment.