summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Sørvig <msorvig@trolltech.com>2009-07-27 12:17:23 (GMT)
committerMorten Sørvig <msorvig@trolltech.com>2009-07-27 12:17:23 (GMT)
commited00fff3cb3f3f1ec01f5d69168222c3ce8d51b2 (patch)
tree67539d58adc2b19c004a04cd91a585cd217044e6 /src
parent8bbe5d242a9534ad29f25f800fcb5b600b3d6750 (diff)
downloadQt-ed00fff3cb3f3f1ec01f5d69168222c3ce8d51b2.zip
Qt-ed00fff3cb3f3f1ec01f5d69168222c3ce8d51b2.tar.gz
Qt-ed00fff3cb3f3f1ec01f5d69168222c3ce8d51b2.tar.bz2
Make the Character Palette work on Mac/Cocoa.
Handle the case when insertText is called with no corresponding keyDown. This fix is for the Cocoa port. Task-number: 147379
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm20
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
2 files changed, 17 insertions, 4 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 3bc348c..57c9117 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -200,6 +200,7 @@ extern "C" {
composingText = new QString();
composing = false;
sendKeyEvents = true;
+ inKeyDown = false;
currentCustomTypes = 0;
[self setHidden:YES];
return self;
@@ -983,6 +984,7 @@ extern "C" {
- (void)keyDown:(NSEvent *)theEvent
{
+ inKeyDown = true;
sendKeyEvents = true;
QWidget *widgetToGetKey = qwidget;
@@ -1002,6 +1004,7 @@ extern "C" {
if (!keyOK && !sendToPopup)
[super keyDown:theEvent];
}
+ inKeyDown = false;
}
@@ -1039,14 +1042,23 @@ extern "C" {
- (void) insertText:(id)aString
{
- if ([aString length] && composing) {
- // Send the commit string to the widget.
- QString commitText;
+ QString commitText;
+ if ([aString length]) {
if ([aString isKindOfClass:[NSAttributedString class]]) {
- commitText = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
+ commitText = QCFString::toQString(reinterpret_cast<CFStringRef>([aString string]));
} else {
commitText = QCFString::toQString(reinterpret_cast<CFStringRef>(aString));
};
+ }
+
+ if ([aString length] && !inKeyDown) {
+ // Handle the case where insertText is called from somewhere else than the keyDown
+ // implementation, for example when inserting text from the character palette.
+ QInputMethodEvent e;
+ e.setCommitString(commitText);
+ qt_sendSpontaneousEvent(qwidget, &e);
+ } else if ([aString length] && composing) {
+ // Send the commit string to the widget.
composing = false;
sendKeyEvents = false;
QInputMethodEvent e;
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 4762b17..932c6ca 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -85,6 +85,7 @@ Q_GUI_EXPORT
bool composing;
int composingLength;
bool sendKeyEvents;
+ bool inKeyDown;
QString *composingText;
QStringList *currentCustomTypes;
NSInteger dragEnterSequence;