From a142d959cdba0406a2c614fadfa9367803c31286 Mon Sep 17 00:00:00 2001 From: Peng Huang Date: Tue, 18 Jan 2011 10:12:40 -0500 Subject: [PATCH] Do not handle release key events, if engine is in init mode. Most application only process key press events, but some process key release events. This change will let Pinyin engine to ignore some release events in init mode, and let applications have chance to get release key events. BUG=none TEST=Test within Ubuntu 10.10 Review URL: http://codereview.appspot.com/3975042 --- src/PYBopomofoEngine.cc | 12 +++++++++++- src/PYPinyinEngine.cc | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/PYBopomofoEngine.cc b/src/PYBopomofoEngine.cc index a46f229..5945eb6 100644 --- a/src/PYBopomofoEngine.cc +++ b/src/PYBopomofoEngine.cc @@ -82,9 +82,19 @@ BopomofoEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers) if (!m_editors[MODE_INIT]->text ().empty ()) m_editors[MODE_INIT]->reset (); m_props.toggleModeChinese (); + return TRUE; } } - return TRUE; + + if (m_input_mode == MODE_INIT && + m_editors[MODE_INIT]->text ().empty ()) { + /* If it is init mode, and no any previouse input text, + * we will let client applications to handle release key event */ + return FALSE; + } + else { + return TRUE; + } } /* Toggle simp/trad Chinese Mode when hotkey Ctrl + Shift + F pressed */ diff --git a/src/PYPinyinEngine.cc b/src/PYPinyinEngine.cc index 9f7c167..f773675 100644 --- a/src/PYPinyinEngine.cc +++ b/src/PYPinyinEngine.cc @@ -84,9 +84,19 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers) if (!m_editors[MODE_INIT]->text ().empty ()) m_editors[MODE_INIT]->reset (); m_props.toggleModeChinese (); + return TRUE; } } - return TRUE; + + if (m_input_mode == MODE_INIT && + m_editors[MODE_INIT]->text ().empty ()) { + /* If it is init mode, and no any previouse input text, + * we will let client applications to handle release key event */ + return FALSE; + } + else { + return TRUE; + } } /* Toggle simp/trad Chinese Mode when hotkey Ctrl + Shift + F pressed */ -- 2.7.4