Transplant cmd key fix to Mac64 branch

--HG--
branch : Mac64
master
Cinder 2014-06-04 07:20:08 -06:00
parent b7ec907d4f
commit 03e396af4b
4 changed files with 23 additions and 10 deletions

View File

@ -27,6 +27,11 @@
#import <Cocoa/Cocoa.h>
#import "llopenglview-objc.h"
// [Cinder] Override NSApplication to give us access to sendEvent
@interface LLNSApplication : NSApplication
@end
// [/Cinder]
@interface LLAppDelegate : NSObject <NSApplicationDelegate> {
LLNSWindow *window;
NSWindow *inputWindow;

View File

@ -392,18 +392,11 @@ attributedStringInfo getSegments(NSAttributedString *str)
[[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSRightArrowFunctionKey)
{
[(LLAppDelegate*)[NSApp delegate] showInputWindow:true withEvent:theEvent];
} else
}
else
{
[[self inputContext] handleEvent:theEvent];
}
// OS X intentionally does not send us key-up information on cmd-key combinations.
// This behaviour is not a bug, and only applies to cmd-combinations (no others).
// Since SL assumes we receive those, we fake it here.
if (mModifiers & NSCommandKeyMask && !mHasMarkedText)
{
callKeyUp([theEvent keyCode], mModifiers);
}
}
- (void)flagsChanged:(NSEvent *)theEvent {

View File

@ -2350,7 +2350,7 @@ if (DARWIN)
set(MACOSX_BUNDLE_BUNDLE_VERSION "${VIEWER_SHORT_VERSION}${VIEWER_MACOSX_PHASE}${VIEWER_REVISION}")
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2010-2014 The Phoenix Firestorm Project, Inc.")
set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "Firestorm.nib")
set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication")
set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "LLNSApplication")
set_target_properties(
${VIEWER_BINARY_NAME}

View File

@ -28,6 +28,21 @@
#include "llwindowmacosx-objc.h"
#include <Carbon/Carbon.h> // Used for Text Input Services ("Safe" API - it's supported)
// [Cinder] We need to override sendEvent in NSApplication and force those
// Apple bastards to send us Command keyUp events!
@implementation LLNSApplication
- (void)sendEvent:(NSEvent *)event {
// Fuck you, conventions!
if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
[[self keyWindow] sendEvent:event];
else
[super sendEvent:event];
}
@end
// [Cinder]
@implementation LLAppDelegate
@synthesize window;