From: Agnelo Vaz Date: Tue, 20 May 2014 20:37:10 +0000 (+0100) Subject: TextInput Emit signal when text is modified. X-Git-Tag: dali-2014-wk21-release~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e04ededcf6627685b262355b66459f0f1d1ac815;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git TextInput Emit signal when text is modified. TextInput emits signal when text is modified, developer can query number of characters on receiving this signal and behaviour accordingly. Change-Id: Ie4794493ec3d724e522475bc53ae43a5dbea8697 --- diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp index e9de775..24710e7 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp @@ -443,6 +443,8 @@ void TextInput::SetText(const std::string& initialText) RemoveHighlight(); DrawCursor(); + + EmitTextModified(); } void TextInput::SetText( const MarkupProcessor::StyledTextArray& styleText ) @@ -488,6 +490,8 @@ void TextInput::SetText( const MarkupProcessor::StyledTextArray& styleText ) Toolkit::Alignment::VerticalTop ) ); mDisplayedTextView.SetLineJustification( leftToRight ? Toolkit::TextView::Left : Toolkit::TextView::Right); } + + EmitTextModified(); } void TextInput::SetMaxCharacterLength(std::size_t maxChars) @@ -535,6 +539,11 @@ Toolkit::TextInput::StyleChangedSignalV2& TextInput::StyleChangedSignal() return mStyleChangedSignalV2; } +Toolkit::TextInput::TextModifiedSignalType& TextInput::TextModifiedSignal() +{ + return mTextModifiedSignal; +} + Toolkit::TextInput::MaxInputCharactersReachedSignalV2& TextInput::MaxInputCharactersReachedSignal() { return mMaxInputCharactersReachedSignalV2; @@ -1044,6 +1053,7 @@ void TextInput::OnKeyInputFocusLost() RemovePreEditStyle(); const std::size_t numberOfCharactersDeleted = DeletePreEdit(); InsertAt( mPreEditString, mPreEditStartPosition, numberOfCharactersDeleted ); + EmitTextModified(); } ImfManager imfManager = ImfManager::Get(); @@ -1622,7 +1632,6 @@ bool TextInput::OnPopupButtonPressed( Toolkit::Button button ) ShowGrabHandleAndSetVisibility( false ); - HidePopup(); } else if(name == OPTION_CLIPBOARD) @@ -1784,6 +1793,7 @@ bool TextInput::OnKeyDownEvent(const KeyEvent& event) // Received key String mCursorPosition = mCursorPosition + InsertAt( Text( keyString ), mCursorPosition, 0 ); update = true; + EmitTextModified(); } } @@ -2234,6 +2244,8 @@ ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfMa mCursorPosition = toDelete; mNumberOfSurroundingCharactersDeleted = numberOfCharacters; + EmitTextModified(); + DALI_LOG_INFO( gLogFilter, Debug::General, "ImfEventReceived - deleteSurrounding post-delete range mCursorPosition[%u] \n", mCursorPosition); break; } @@ -2325,6 +2337,7 @@ bool TextInput::PreEditReceived(const std::string& keyString, std::size_t cursor mDisplayedTextView.RemoveTextFrom( mPreEditStartPosition, numberOfCharactersToReplace ); } GetTextLayoutInfo(); + EmitTextModified(); } else { @@ -2334,6 +2347,7 @@ bool TextInput::PreEditReceived(const std::string& keyString, std::size_t cursor mCursorPosition = mPreEditStartPosition + std::min( cursorOffset, mPreEditLength ); ApplyPreEditStyle( mPreEditStartPosition, mPreEditLength ); DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReceived mCursorPosition[%u] \n", mCursorPosition); + EmitTextModified(); } // cursor update to keyboard is not done here as the keyboard knows the cursor position and provides the 'cursorOffset'. DrawCursor(); @@ -2353,9 +2367,9 @@ bool TextInput::PreEditReceived(const std::string& keyString, std::size_t cursor mCursorPosition = mPreEditStartPosition + std::min( cursorOffset, mPreEditLength ); ApplyPreEditStyle( mPreEditStartPosition, mPreEditLength ); DALI_LOG_INFO(gLogFilter, Debug::General, "PreEditReceived mCursorPosition[%u] mPreEditStartPosition[%u]\n", mCursorPosition, mPreEditStartPosition); - // cursor update to keyboard is not done here as the keyboard knows the cursor position and provides the 'cursorOffset'. DrawCursor(); + EmitTextModified(); } else { @@ -2416,6 +2430,8 @@ bool TextInput::CommitReceived(const std::string& keyString ) } } + EmitTextModified(); + if ( mSelectTextOnCommit ) { SelectText(mRequestedSelection.mStartOfSelection, mRequestedSelection.mEndOfSelection ); @@ -2437,6 +2453,7 @@ bool TextInput::CommitReceived(const std::string& keyString ) mCursorPosition = mCursorPosition + InsertAt( Text( keyString ), mCursorPosition, mNumberOfSurroundingCharactersDeleted ); update = true; mNumberOfSurroundingCharactersDeleted = 0; + EmitTextModified(); } else { @@ -5092,11 +5109,18 @@ void TextInput::GetTextLayoutInfo() void TextInput::EmitStyleChangedSignal() { // emit signal if input style changes. - Toolkit::TextInput handle( GetOwner() ); mStyleChangedSignalV2.Emit( handle, mInputStyle ); } +void TextInput::EmitTextModified() +{ + // emit signal when text changes. + Toolkit::TextInput handle( GetOwner() ); + mTextModifiedSignal.Emit( handle ); +} + + void TextInput::EmitMaxInputCharactersReachedSignal() { // emit signal if max characters is reached during text input. diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h b/base/dali-toolkit/internal/controls/text-input/text-input-impl.h index 1712d2e..636f234 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.h +++ b/base/dali-toolkit/internal/controls/text-input/text-input-impl.h @@ -130,6 +130,11 @@ public: Toolkit::TextInput::StyleChangedSignalV2& StyleChangedSignal(); /** + * @copydoc Toolkit::TextInput::TextModifiedSignal() + */ + Toolkit::TextInput::TextModifiedSignalType& TextModifiedSignal(); + + /** * @copydoc Toolkit::TextInput::MaxInputCharactersReachedSignal() */ Toolkit::TextInput::MaxInputCharactersReachedSignalV2& MaxInputCharactersReachedSignal(); @@ -1316,6 +1321,11 @@ public: // Public to allow internal testing. void EmitStyleChangedSignal(); /** + * Emit signal when text is modified. + */ + void EmitTextModified(); + + /** * Emits max input characters reached signal. */ void EmitMaxInputCharactersReachedSignal(); @@ -1445,6 +1455,7 @@ private: Toolkit::TextInput::InputSignalV2 mInputStartedSignalV2; ///< Signal emitted when input starts Toolkit::TextInput::InputSignalV2 mInputFinishedSignalV2; ///< Signal emitted when input ends Toolkit::TextInput::StyleChangedSignalV2 mStyleChangedSignalV2; ///< Signal emitted when style changes. + Toolkit::TextInput::TextModifiedSignalType mTextModifiedSignal; ///< Signal emitted when text modified. Toolkit::TextInput::MaxInputCharactersReachedSignalV2 mMaxInputCharactersReachedSignalV2; ///< Signal emitted when max input characters is reached. Toolkit::TextInput::InputSignalV2 mCutAndPasteToolBarDisplayedV2; ///< Signal emitted when toolbar displayed Toolkit::TextInput::InputTextExceedBoundariesSignalV2 mInputTextExceedBoundariesSignalV2; ///< Signal emitted when input text exceeds the boundaries of the text-input. diff --git a/base/dali-toolkit/public-api/controls/text-input/text-input.cpp b/base/dali-toolkit/public-api/controls/text-input/text-input.cpp index ff15d35..ed566de 100644 --- a/base/dali-toolkit/public-api/controls/text-input/text-input.cpp +++ b/base/dali-toolkit/public-api/controls/text-input/text-input.cpp @@ -343,6 +343,11 @@ TextInput::StyleChangedSignalV2& TextInput::StyleChangedSignal() return GetImpl(*this).StyleChangedSignal(); } +TextInput::TextModifiedSignalType& TextInput::TextModifiedSignal() +{ + return GetImpl(*this).TextModifiedSignal(); +} + TextInput::MaxInputCharactersReachedSignalV2& TextInput::MaxInputCharactersReachedSignal() { return GetImpl(*this).MaxInputCharactersReachedSignal(); diff --git a/capi/dali-toolkit/public-api/controls/text-input/text-input.h b/capi/dali-toolkit/public-api/controls/text-input/text-input.h index 68cde3d..cd672c3 100644 --- a/capi/dali-toolkit/public-api/controls/text-input/text-input.h +++ b/capi/dali-toolkit/public-api/controls/text-input/text-input.h @@ -547,6 +547,9 @@ public: /* Signals */ /// @brief Input style changed signal. typedef SignalV2< void ( TextInput textInput, const TextStyle& style ) > StyleChangedSignalV2; + /// @brief Text modified signal. + typedef SignalV2< void ( TextInput textInput ) > TextModifiedSignalType; + /// @brief Max input characters reached signal. typedef SignalV2< void ( TextInput textInput ) > MaxInputCharactersReachedSignalV2; @@ -581,6 +584,13 @@ public: /* Signals */ StyleChangedSignalV2& StyleChangedSignal(); /** + * @brief Signal emitted when text changes. + * + * @return The signal to connect to. + */ + TextModifiedSignalType& TextModifiedSignal(); + + /** * @brief Signal emitted when max input characters are reached during text input. * * @return The signal to connect to