Jean-Marc Lasgouttes wrote:
> I was just pointing out that someone has to do it :)

Here's a patch that does it and also fixes the math superscript problem of 
Jos�'s original patch (the circumflex key didn't trigger superscript inside 
mathed).

I apply it to 1.3 and the corresponding patch to 1.4 if Jos� and you are fine 
with it.

J�rgen
Index: QContentPane.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v
retrieving revision 1.18.2.2
diff -u -r1.18.2.2 QContentPane.C
--- QContentPane.C	7 Dec 2004 10:49:10 -0000	1.18.2.2
+++ QContentPane.C	26 May 2005 11:23:09 -0000
@@ -96,12 +96,46 @@
 	setFocusPolicy(QWidget::WheelFocus);
 	setFocus();
 	setCursor(ibeamCursor);
+#if QT_VERSION >= 0x030200
+	// to make qt-immodule work
+	setInputMethodEnabled(true);
+#endif
 
 	// stupid moc strikes again
 	connect(wa_->scrollbar_, SIGNAL(valueChanged(int)),
 		this, SLOT(scrollBarChanged(int)));
 
 }
+
+
+#if QT_VERSION >= 0x030000
+// to make qt-immodule work
+void QContentPane::imStartEvent(QIMEvent *e)
+{
+	e->accept();
+}
+
+
+void QContentPane::imComposeEvent(QIMEvent *e)
+{
+	e->accept();
+}
+
+
+void QContentPane::imEndEvent(QIMEvent *e)
+{
+	if (!e->text().isEmpty()) {
+		int key = 0;
+		// needed to make math superscript work
+		if (e->text() == "^")
+			key = Qt::Key_AsciiCircum;
+		QKeyEvent ev(QEvent::KeyPress, key,
+			*e->text().ascii(), 0, e->text());
+		keyPressEvent(&ev);
+	}
+	e->accept();
+}
+#endif
 
 
 void QContentPane::scrollBarChanged(int val)
Index: QContentPane.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.h,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 QContentPane.h
--- QContentPane.h	7 Dec 2004 10:49:10 -0000	1.7.2.2
+++ QContentPane.h	26 May 2005 11:23:09 -0000
@@ -97,6 +97,13 @@
 	void wheelEvent(QWheelEvent * e);
 	/// key press
 	void keyPressEvent(QKeyEvent * e);
+#if QT_VERSION >= 0x030000
+	/// IM events
+	void imStartEvent(QIMEvent *);
+	void imComposeEvent(QIMEvent *);
+	void imEndEvent(QIMEvent *);
+#endif
+
 public slots:
 	void doubleClickTimeout();
 

Reply via email to