X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=fc372af0467c55d1ef78fce49b0f6067a879126d;hp=52c64ddbcb7eed720576a2d370d02e6e17854038;hb=efee55c67553d0a2be7b5e7f8dbe5d7b8d9c52b3;hpb=a53706fd985dcbed954d7438222e4adf898c3500 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 52c64dd..fc372af 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -23,6 +23,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -84,6 +85,17 @@ void Controller::SetText( const std::string& text ) CharacterIndex lastCursorIndex = 0u; + if( mImpl->mEventData ) + { + // If popup shown then hide it by switching to Editing state + if ( EventData::SELECTING == mImpl->mEventData->mState || + EventData::SELECTION_CHANGED == mImpl->mEventData->mState || + EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) + { + mImpl->ChangeState( EventData::EDITING ); + } + } + if( !text.empty() ) { // Convert text into UTF-32 @@ -1140,6 +1152,11 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) { textChanged = BackspaceKeyEvent(); } + else if ( IsKey( keyEvent, Dali::DALI_KEY_POWER ) || IsKey( keyEvent, Dali::DALI_KEY_MENU ) ) + { + // Do nothing when the Power or Menu Key is pressed. + // It avoids call the InsertText() method and delete the selected text. + } else { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() ); @@ -1220,6 +1237,8 @@ void Controller::InsertText( const std::string& text, Controller::InsertType typ ResetText(); } + mImpl->ChangeState( EventData::EDITING ); + // Handle the IMF (predicitive text) state changes if( mImpl->mEventData ) { @@ -1325,19 +1344,18 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y ) const bool isShowingPlaceholderText = mImpl->IsShowingPlaceholderText(); if( 1u == tapCount ) { - bool tapDuringEditMode( EventData::EDITING == mImpl->mEventData->mState ); - - if( !isShowingPlaceholderText && tapDuringEditMode ) + if( !isShowingPlaceholderText && + ( EventData::EDITING == mImpl->mEventData->mState ) ) { mImpl->mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true ); mImpl->mEventData->mDecorator->SetPopupActive( false ); } - mImpl->ChangeState( EventData::EDITING ); - // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated if( mImpl->mEventData ) { + mImpl->ChangeState( EventData::EDITING ); + Event event( Event::TAP_EVENT ); event.p1.mUint = tapCount; event.p2.mFloat = x; @@ -1463,6 +1481,20 @@ void Controller::DecorationEvent( HandleType handleType, HandleState state, floa } } +void Controller::PasteText( const std::string& stringToPaste ) +{ + InsertText( stringToPaste, Text::Controller::COMMIT ); + mImpl->ChangeState( EventData::EDITING ); + mImpl->RequestRelayout(); +} + +void Controller::PasteClipboardItemEvent() +{ + ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); + std::string stringToPaste( notifier.GetContent() ); + PasteText( stringToPaste ); +} + void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button ) { if( NULL == mImpl->mEventData ) @@ -1500,9 +1532,7 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt { std::string stringToPaste(""); mImpl->GetTextFromClipboard( 0, stringToPaste ); // Paste latest item from system clipboard - InsertText( stringToPaste, Text::Controller::CLIPBOARD ); - mImpl->ChangeState( EventData::EDITING ); - mImpl->RequestRelayout(); + PasteText( stringToPaste ); break; } case Toolkit::TextSelectionPopup::SELECT: @@ -1524,6 +1554,7 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt } case Toolkit::TextSelectionPopup::CLIPBOARD: { + mImpl->ShowClipboard(); break; } case Toolkit::TextSelectionPopup::NONE: @@ -1599,7 +1630,6 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons return callbackData; } - Controller::~Controller() { delete mImpl;