add enter key press handle.
authorPeng Wu <alexepico@gmail.com>
Tue, 22 Jun 2010 07:08:19 +0000 (15:08 +0800)
committerPeng Wu <alexepico@gmail.com>
Tue, 22 Jun 2010 07:08:19 +0000 (15:08 +0800)
src/ExtEditor.cc
src/ExtEditor.h

index 28ea59a..305c8c1 100644 (file)
@@ -98,6 +98,9 @@ ExtEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
     if (processSpace (keyval))
         return TRUE;
 
+    if (processEnter (keyval))
+        return TRUE;
+
     m_cursor = std::min (m_cursor, (guint)m_text.length ());
 
     /* Remember the input string. */
@@ -272,6 +275,21 @@ ExtEditor::processSpace (guint keyval)
     return TRUE;
 }
 
+gboolean
+ExtEditor::processEnter(guint keyval)
+{
+    if ( !(keyval == IBUS_KP_Enter ) )
+        return FALSE;
+
+    if ( m_text.length() == 0 )
+        return FALSE;
+
+    Text text(m_text);
+    commitText(text);
+    reset();
+    return TRUE;
+}
+
 void
 ExtEditor::pageUp (void)
 {
index 9ff1975..26bedb3 100644 (file)
@@ -67,6 +67,7 @@ private:
     gboolean processLabelKey (guint keyval);
 
     gboolean processSpace (guint keyval);
+    gboolean processEnter (guint keyval);
 
     gboolean removeCharBefore (void);
     gboolean removeCharAfter (void);