From 95fc96d9b7b0118e1a10ff0f1326c7bcfda3a7db Mon Sep 17 00:00:00 2001 From: "yanjie.hu" Date: Tue, 2 Apr 2013 20:22:18 +0800 Subject: [PATCH] Adapt auto capitalize feature Change-Id: I19654e6d5bff53e28a2347a186b0521e7e117b68 --- scl/include/sclui.h | 2 ++ scl/include/scluiimpl.h | 3 +++ scl/scleventhandler.cpp | 17 +++++------------ scl/sclui.cpp | 18 ++++++++++++++++++ scl/scluiimpl.cpp | 13 +++++++++++++ 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/scl/include/sclui.h b/scl/include/sclui.h index 64f8815..60f1ae6 100644 --- a/scl/include/sclui.h +++ b/scl/include/sclui.h @@ -351,6 +351,8 @@ public: */ void unset_string_substitution(const sclchar *original); + sclint get_caps_mode(); + void set_caps_mode(sclint); private: CSCLUIImpl *m_impl; }; diff --git a/scl/include/scluiimpl.h b/scl/include/scluiimpl.h index c5e75bf..edb9680 100644 --- a/scl/include/scluiimpl.h +++ b/scl/include/scluiimpl.h @@ -109,8 +109,11 @@ public: void set_string_substitution(const sclchar *original, const sclchar *substitute); void unset_string_substitution(const sclchar *original); + sclint get_caps_mode(); + void set_caps_mode(sclint caps_mode); private: sclboolean m_initialized; + sclint m_caps_mode; }; } diff --git a/scl/scleventhandler.cpp b/scl/scleventhandler.cpp index 17bae7c..3c21623 100644 --- a/scl/scleventhandler.cpp +++ b/scl/scleventhandler.cpp @@ -100,6 +100,9 @@ static void handle_shift_state_on_button_click_event(SclUIEventDesc ui_event_des if (ui_event_desc.key_type == KEY_TYPE_MODECHANGE) { turn_shift_off = FALSE; } + if (uiimpl->get_caps_mode()) { + turn_shift_off = FALSE; + } } /* If we are in ON_PRESSED or ON_KEY_ENTERED mode of shift multi touch state, do not turn it off now */ if (context->get_shift_multi_touch_enabled() && turn_shift_off) { @@ -115,14 +118,7 @@ static void handle_shift_state_on_button_click_event(SclUIEventDesc ui_event_des } if (turn_shift_off) { if (uiimpl->get_shift_state() == SCL_SHIFT_STATE_ON) { - /* If the ISE doesn't care about changing the shift state to off */ - CSCLEventHandler *handler = CSCLEventHandler::get_instance(); - if (handler) { - if (SCL_EVENT_PASS_ON == - handler->on_event_notification(SCL_UINOTITYPE_SHIFT_STATE_CHANGE, SCL_SHIFT_STATE_OFF)) { - uiimpl->set_shift_state(SCL_SHIFT_STATE_OFF); - } - } + uiimpl->set_shift_state(SCL_SHIFT_STATE_OFF); } } } @@ -204,10 +200,7 @@ CSCLEventHandler::on_event_drag_state_changed(SclUIEventDesc ui_event_desc) if (context) { if (ui_event_desc.key_event == MVK_Shift_L) { if (context->get_shift_multi_touch_state() == SCL_SHIFT_MULTITOUCH_OFF) { - if (SCL_EVENT_PASS_ON == - on_event_notification(SCL_UINOTITYPE_SHIFT_STATE_CHANGE, SCL_SHIFT_STATE_ON)) { - uiimpl->set_shift_state(SCL_SHIFT_STATE_ON); - } + uiimpl->set_shift_state(SCL_SHIFT_STATE_ON); context->set_shift_multi_touch_state(SCL_SHIFT_MULTITOUCH_ON_PRESSED); } } diff --git a/scl/sclui.cpp b/scl/sclui.cpp index 25b4c53..1a315b6 100644 --- a/scl/sclui.cpp +++ b/scl/sclui.cpp @@ -539,3 +539,21 @@ CSCLUI::unset_string_substitution(const sclchar *original) m_impl->unset_string_substitution(original); } } + +void +CSCLUI::set_caps_mode(sclint mode) { + if (m_impl) { + m_impl->set_caps_mode(mode); + } +} + +sclint +CSCLUI::get_caps_mode() { + sclint mode = 0; + + if (m_impl) { + mode = m_impl->get_caps_mode(); + } + + return mode; +} diff --git a/scl/scluiimpl.cpp b/scl/scluiimpl.cpp index 7683b06..437d9ac 100644 --- a/scl/scluiimpl.cpp +++ b/scl/scluiimpl.cpp @@ -905,3 +905,16 @@ CSCLUIImpl::unset_string_substitution(const sclchar *original) } } } + +void +CSCLUIImpl::set_caps_mode(sclint mode) { + m_caps_mode = mode; + if (get_shift_state() != SCL_SHIFT_STATE_LOCK) { + set_shift_state(mode ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF); + } +} + +sclint +CSCLUIImpl::get_caps_mode() { + return m_caps_mode; +} -- 2.7.4