From 8366c516088c6ffbfc04063dc4219f33c541b1fe Mon Sep 17 00:00:00 2001 From: rti Date: Wed, 7 Jul 2010 02:01:15 +0200 Subject: [PATCH] Fixed: #1012 Dead Keys Broken --- .../src/3d/driver/opengl/mac/cocoa_adapter.mm | 20 +++++++++++------ .../3d/driver/opengl/mac/cocoa_opengl_view.h | 22 ------------------- .../3d/driver/opengl/mac/cocoa_opengl_view.m | 14 ++---------- 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm b/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm index 9da4b4d45..aa0cf9dbb 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_adapter.mm @@ -149,9 +149,6 @@ static void setupGLView(NSView* superview) // free the pixel format object [format release]; - - // let this view receive be target of events - [view becomeFirstResponder]; } void ctor() @@ -245,6 +242,8 @@ nlWindow setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool resizeabl setupGLView(view); + [[view window] makeFirstResponder:[[view subviews] lastObject]]; + return view; } @@ -274,6 +273,12 @@ bool setWindowStyle(nlWindow wnd, bool fullscreen) // pull the view back from fullscreen restoring window options [superview exitFullScreenModeWithOptions:nil]; + + // let the gl view receive key events + [[view window] makeFirstResponder:view]; + + // bring the window containing the gl view to the front + [[view window] makeKeyAndOrderFront:nil]; } // enter fullscreen, leave windowed mode @@ -302,6 +307,9 @@ bool setWindowStyle(nlWindow wnd, bool fullscreen) TODO check if simply using NSView enterFullScreenMode is a good idea. the context can be set to full screen as well, performance differences? */ + + // let the gl view receive key events + [[view window] makeFirstResponder:view]; } return true; @@ -785,8 +793,8 @@ void submitEvents(NLMISC::CEventServer& server, if(!event) break; - NSRect viewRect = - [[[[[event window] contentView] subviews] lastObject] frame]; + NSView* glView = [[[[event window] contentView] subviews] lastObject]; + NSRect viewRect = [glView frame]; // TODO this code assumes, that the view fills the window // convert the mouse position to NeL style (relative) @@ -798,7 +806,6 @@ void submitEvents(NLMISC::CEventServer& server, event.type != NSKeyDown && event.type != NSKeyUp) { [NSApp sendEvent:event]; - [NSApp updateWindows]; continue; } @@ -857,7 +864,6 @@ void submitEvents(NLMISC::CEventServer& server, nelEvent = new NLMISC::CEventMouseMove(mouseX, mouseY, (NLMISC::TMouseButton)0 /* modifiers */, eventEmitter); - server.postEvent(nelEvent); break; } diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.h b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.h index 1ccc7e9e2..11bb87cc7 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.h +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.h @@ -29,28 +29,6 @@ -(id)initWithFrame:(NSRect)frame; -(void)dealloc; - --(BOOL)acceptsFirstResponder; --(BOOL)needsPanelToBecomeKey; -(void)keyDown:(NSEvent*)event; -/******************************************************************************/ -/* NSTextInputClient Protocol */ - --(BOOL)hasMarkedText; --(NSRange)markedRange; --(NSRange)selectedRange; --(void)setMarkedText:(id)aString - selectedRange:(NSRange)newSelection - replacementRange:(NSRange)replacementRange; --(void)unmarkText; --(NSArray*)validAttributesForMarkedText; --(NSAttributedString*)attributedSubstringForProposedRange:(NSRange)aRange - actualRange:(NSRangePointer)actualRange; --(void)insertText:(id)aString replacementRange:(NSRange)replacementRange; --(NSUInteger)characterIndexForPoint:(NSPoint)aPoint; --(NSRect)firstRectForCharacterRange:(NSRange)aRange - actualRange:(NSRangePointer)actualRange; --(void)doCommandBySelector:(SEL)aSelector; - @end diff --git a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m index c9c080dd6..fbb43f5fc 100644 --- a/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m +++ b/code/nel/src/3d/driver/opengl/mac/cocoa_opengl_view.m @@ -20,7 +20,7 @@ @implementation CocoaOpenGLView -- (id)initWithFrame:(NSRect)frame +-(id)initWithFrame:(NSRect)frame { if(self = [super initWithFrame:frame]) { @@ -30,22 +30,12 @@ return nil; } -- (void)dealloc +-(void)dealloc { [characterStorage release]; [super dealloc]; } --(BOOL)acceptsFirstResponder -{ - return YES; -} - --(BOOL)needsPanelToBecomeKey -{ - return NO; -} - -(void)keyDown:(NSEvent*)event { [[self inputContext] handleEvent:event];