Mercurial > sdl-ios-xcode
comparison src/video/cocoa/SDL_cocoawindow.m @ 4927:d716dff4b13e
Fixed touch events on Mac OS X 10.6
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 02 Dec 2010 11:56:23 -0800 |
parents | 514f811a4887 |
children | 24d44c7c4c63 |
comparison
equal
deleted
inserted
replaced
4926:ab02a7242f08 | 4927:d716dff4b13e |
---|---|
55 [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:_data->nswindow]; | 55 [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:_data->nswindow]; |
56 [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:_data->nswindow]; | 56 [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:_data->nswindow]; |
57 } else { | 57 } else { |
58 [_data->nswindow setDelegate:self]; | 58 [_data->nswindow setDelegate:self]; |
59 } | 59 } |
60 // FIXME: Why doesn't this work? | |
61 // [center addObserver:self selector:@selector(rightMouseDown:) name:[NSString stringWithCString:"rightMouseDown" encoding:NSUTF8StringEncoding] object:[_data->nswindow contentView]]; | |
60 [center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp]; | 62 [center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp]; |
61 [center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp]; | 63 [center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp]; |
62 | 64 |
63 [_data->nswindow setAcceptsMouseMovedEvents:YES]; | 65 [_data->nswindow setAcceptsMouseMovedEvents:YES]; |
64 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 | 66 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 |
65 [[_data->nswindow contentView] setAcceptsTouchEvents:YES]; | 67 [[_data->nswindow contentView] setAcceptsTouchEvents:YES]; |
66 #endif | 68 #endif |
67 } | 69 } |
68 | 70 |
69 - (void)close | 71 - (void)close |
293 [self handleTouches:COCOA_TOUCH_CANCELLED withEvent:theEvent]; | 295 [self handleTouches:COCOA_TOUCH_CANCELLED withEvent:theEvent]; |
294 } | 296 } |
295 | 297 |
296 - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event | 298 - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event |
297 { | 299 { |
298 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 | 300 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 |
299 NSSet *touches = 0; | 301 NSSet *touches = 0; |
300 NSEnumerator *enumerator; | 302 NSEnumerator *enumerator; |
301 NSTouch *touch; | 303 NSTouch *touch; |
302 | 304 |
303 switch (type) { | 305 switch (type) { |
355 break; | 357 break; |
356 } | 358 } |
357 | 359 |
358 touch = (NSTouch*)[enumerator nextObject]; | 360 touch = (NSTouch*)[enumerator nextObject]; |
359 } | 361 } |
360 #endif /* MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 */ | 362 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 */ |
361 } | 363 } |
362 | 364 |
363 @end | 365 @end |
364 | 366 |
365 @interface SDLWindow : NSWindow | 367 @interface SDLWindow : NSWindow |
435 { | 437 { |
436 SDL_Rect bounds; | 438 SDL_Rect bounds; |
437 NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; | 439 NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; |
438 NSView *contentView = [[SDLView alloc] initWithFrame: rect | 440 NSView *contentView = [[SDLView alloc] initWithFrame: rect |
439 listener: data->listener]; | 441 listener: data->listener]; |
442 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | |
443 [contentView setAcceptsTouchEvents:YES]; | |
444 #endif | |
440 [nswindow setContentView: contentView]; | 445 [nswindow setContentView: contentView]; |
441 [contentView release]; | 446 [contentView release]; |
442 | 447 |
443 ConvertNSRect(&rect); | 448 ConvertNSRect(&rect); |
444 Cocoa_GetDisplayBounds(_this, display, &bounds); | 449 Cocoa_GetDisplayBounds(_this, display, &bounds); |