Cocoa: Handle insertNewLine selector for when it is sent while composing text

Some IMEs will perform an insertNewLine when Return/Enter is pressed while
composing text as well as causing the edit to finish. By handling this it
will ensure that the extra enter/return event is sent when the IME
requests it.

Task-id: QTBUG-39125
Change-Id: Ice6eded68e6b1dc51703a38316f76f78099923da
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
Andy Shaw 2014-08-22 14:19:04 +02:00
parent 1fa3627423
commit a5df2e7120
2 changed files with 11 additions and 0 deletions

View File

@ -78,6 +78,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper);
bool m_shouldSetGLContextinDrawRect; bool m_shouldSetGLContextinDrawRect;
NSString *m_inputSource; NSString *m_inputSource;
QNSViewMouseMoveHelper *m_mouseMoveHelper; QNSViewMouseMoveHelper *m_mouseMoveHelper;
bool m_resendKeyEvent;
} }
- (id)init; - (id)init;

View File

@ -149,6 +149,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_sendUpAsRightButton = false; m_sendUpAsRightButton = false;
m_inputSource = 0; m_inputSource = 0;
m_mouseMoveHelper = [[QNSViewMouseMoveHelper alloc] initWithView:self]; m_mouseMoveHelper = [[QNSViewMouseMoveHelper alloc] initWithView:self];
m_resendKeyEvent = false;
if (!touchDevice) { if (!touchDevice) {
touchDevice = new QTouchDevice; touchDevice = new QTouchDevice;
@ -1402,6 +1403,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
} }
} }
} }
if (m_resendKeyEvent)
m_sendKeyEvent = true;
} }
if (m_sendKeyEvent && m_composingText.isEmpty()) if (m_sendKeyEvent && m_composingText.isEmpty())
@ -1409,6 +1412,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat]); nativeScanCode, nativeVirtualKey, nativeModifiers, text, [nsevent isARepeat]);
m_sendKeyEvent = false; m_sendKeyEvent = false;
m_resendKeyEvent = false;
} }
- (void)keyDown:(NSEvent *)nsevent - (void)keyDown:(NSEvent *)nsevent
@ -1479,6 +1483,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
} }
} }
- (void) insertNewline:(id)sender
{
Q_UNUSED(sender);
m_resendKeyEvent = true;
}
- (void) doCommandBySelector:(SEL)aSelector - (void) doCommandBySelector:(SEL)aSelector
{ {
[self tryToPerform:aSelector with:self]; [self tryToPerform:aSelector with:self];