From bcbdc0b7654fb74b6527ee371deb61257abcf7a9 Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Thu, 3 Sep 2015 17:42:41 +0100 Subject: [PATCH] Notify the IMF when backspace/cut empties the TextField (This is the reset the virtual keyboard to upper-case) Change-Id: Ia450bda4c58948ead2dbdd41a21e91cbe27b3524 --- dali-toolkit/internal/text/text-controller.cpp | 29 ++++++++++++++++++++++++++ dali-toolkit/internal/text/text-controller.h | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index a0302bc..f24e69a 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1713,6 +1713,13 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt { mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text mImpl->mOperationsPending = ALL_OPERATIONS; + + // This is to reset the virtual keyboard to Upper-case + if( 0u == mImpl->mLogicalModel->mText.Count() ) + { + NotifyImfManager(); + } + if( 0u != mImpl->mLogicalModel->mText.Count() || !mImpl->IsPlaceholderAvailable() ) { @@ -1876,6 +1883,12 @@ bool Controller::BackspaceKeyEvent() if( removed ) { + // This is to reset the virtual keyboard to Upper-case + if( 0u == mImpl->mLogicalModel->mText.Count() ) + { + NotifyImfManager(); + } + if( 0u != mImpl->mLogicalModel->mText.Count() || !mImpl->IsPlaceholderAvailable() ) { @@ -1891,6 +1904,22 @@ bool Controller::BackspaceKeyEvent() return removed; } +void Controller::NotifyImfManager() +{ + ImfManager imfManager = ImfManager::Get(); + + if( imfManager ) + { + // Notifying IMF of a cursor change triggers a surrounding text request so updating it now. + std::string text; + GetText( text ); + imfManager.SetSurroundingText( text ); + + imfManager.SetCursorPosition( GetLogicalCursorPosition() ); + imfManager.NotifyCursorPosition(); + } +} + void Controller::ShowPlaceholderText() { if( mImpl->IsPlaceholderAvailable() ) diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index e665ac2..3c6125d 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -643,6 +643,11 @@ private: bool BackspaceKeyEvent(); /** + * @brief Helper to notify IMF manager with surrounding text & cursor changes. + */ + void NotifyImfManager(); + + /** * @brief Helper to clear font-specific data. */ void ShowPlaceholderText(); -- 2.7.4