summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm14
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp15
3 files changed, 26 insertions, 4 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 19367d1..2d6f5ad 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -195,6 +195,7 @@ extern "C" {
if (self) {
[self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
}
+ composingText = new QString();
composing = false;
sendKeyEvents = true;
[self setHidden:YES];
@@ -364,6 +365,7 @@ extern "C" {
- (void)dealloc
{
+ delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
@@ -917,7 +919,7 @@ extern "C" {
- (void) insertText:(id)aString
{
- if (composing) {
+ if ([aString length]) {
// Send the commit string to the widget.
QString commitText;
if ([aString isKindOfClass:[NSAttributedString class]]) {
@@ -931,6 +933,7 @@ extern "C" {
e.setCommitString(commitText);
qt_sendSpontaneousEvent(qwidget, &e);
}
+ composingText->clear();
}
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
@@ -984,12 +987,21 @@ extern "C" {
attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
0, composingLength, format);
}
+ *composingText = qtText;
QInputMethodEvent e(qtText, attrs);
qt_sendSpontaneousEvent(qwidget, &e);
+ if (!composingLength)
+ composing = false;
}
- (void) unmarkText
{
+ if (composing) {
+ QInputMethodEvent e;
+ e.setCommitString(*composingText);
+ qt_sendSpontaneousEvent(qwidget, &e);
+ }
+ composingText->clear();
composing = false;
}
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 9de94d5..ec1281e 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -83,6 +83,7 @@ Q_GUI_EXPORT
bool composing;
int composingLength;
bool sendKeyEvents;
+ QString *composingText;
}
- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
- (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 1a0fb08..39abc5e 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -48,6 +48,7 @@
#include <qinputcontext.h>
#include <private/qkeymapper_p.h>
#include <private/qapplication_p.h>
+#include <private/qmacinputcontext_p.h>
QT_BEGIN_NAMESPACE
@@ -480,7 +481,8 @@ static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent,
#ifdef QT_MAC_USE_COCOA
if (outHandled) {
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, keyEvent);
+ if (er)
+ CallNextEventHandler(er, keyEvent);
*outHandled = qt_mac_eat_unicode_key;
}
#endif
@@ -692,8 +694,14 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
return true;
}
- if (qApp->inputContext() && qApp->inputContext()->isComposing())
+ if (qApp->inputContext() && qApp->inputContext()->isComposing()) {
+ if (ekind == kEventRawKeyDown) {
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context)
+ context->setLastKeydownEvent(event);
+ }
return false;
+ }
//get modifiers
Qt::KeyboardModifiers modifiers;
int qtKey;
@@ -721,7 +729,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
//is it of use to text services? If so we won't bother
//with a QKeyEvent.
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, event);
+ if (er)
+ CallNextEventHandler(er, event);
extern bool qt_mac_menubar_is_open();
if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
return true;