imfManager.SetRestoreAfterFocusLost( true );
}
+ ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+
+ if ( notifier )
+ {
+ notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected );
+ }
+
mController->KeyboardFocusGainEvent();
EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
imfManager.EventReceivedSignal().Disconnect( this, &TextField::OnImfEvent );
}
+ ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+
+ if ( notifier )
+ {
+ notifier.ContentSelectedSignal().Disconnect( this, &TextField::OnClipboardTextSelected );
+ }
+
mController->KeyboardFocusLostEvent();
EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
}
}
+void TextField::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
+{
+ mController->PasteClipboardItemEvent();
+}
+
void TextField::KeyboardStatusChanged(bool keyboardShown)
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown );
#include <dali-toolkit/internal/text/text-controller.h>
#include <dali-toolkit/internal/text/rendering/text-renderer.h>
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
+
namespace Dali
{
*/
ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
+ /**
+ * @brief Callback when Clipboard signals an item should be pasted
+ * @param[in] clipboard handle to Clipboard Event Notifier
+ */
+ void OnClipboardTextSelected( ClipboardEventNotifier& clipboard );
+
private: // Implementation
/**
}
}
+void Controller::Impl::ShowClipboard()
+{
+ if ( mClipboard )
+ {
+ mClipboard.ShowClipboard();
+ }
+}
+
+void Controller::Impl::HideClipboard()
+{
+ if ( mClipboard )
+ {
+ mClipboard.HideClipboard();
+ }
+}
+
bool Controller::Impl::CopyStringToClipboard( std::string& source )
{
//Send string to clipboard
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetPopupActive( false );
mEventData->mDecoratorUpdated = true;
+ HideClipboard();
}
else if ( EventData::SELECTING == mEventData->mState )
{
if ( !IsClipboardEmpty() )
{
buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
}
mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow );
if ( !IsClipboardEmpty() )
{
buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
}
mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow );
mEventData->mDecorator->SetPopupActive( false );
}
mEventData->mDecoratorUpdated = true;
+ HideClipboard();
}
else if( EventData::EDITING_WITH_POPUP == mEventData->mState )
{
if ( !IsClipboardEmpty() )
{
buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
}
mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow );
mEventData->mDecorator->SetPopupActive( true );
}
+ HideClipboard();
mEventData->mDecoratorUpdated = true;
}
else if ( EventData::SELECTION_HANDLE_PANNING == mEventData->mState )
void RetrieveSelection( std::string& selectedText, bool deleteAfterRetreival );
+ void ShowClipboard();
+
+ void HideClipboard();
+
bool CopyStringToClipboard( std::string& source );
void SendSelectionToClipboard( bool deleteAfterSending );
#include <iostream>
#include <dali/public-api/adaptor-framework/key.h>
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/bidirectional-support.h>
}
}
+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 )
{
std::string stringToPaste("");
mImpl->GetTextFromClipboard( 0, stringToPaste ); // Paste latest item from system clipboard
- InsertText( stringToPaste, Text::Controller::COMMIT );
- mImpl->ChangeState( EventData::EDITING );
- mImpl->RequestRelayout();
+ PasteText( stringToPaste );
break;
}
case Toolkit::TextSelectionPopup::SELECT:
}
case Toolkit::TextSelectionPopup::CLIPBOARD:
{
+ mImpl->ShowClipboard();
break;
}
case Toolkit::TextSelectionPopup::NONE:
return callbackData;
}
-
Controller::~Controller()
{
delete mImpl;
ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
/**
+ * @brief Paste given string into Text model
+ * @param[in] stringToPaste this string will be inserted into the text model
+ */
+ void PasteText( const std::string& stringToPaste );
+
+ /**
+ * @brief Event from Clipboard notifying an Item has been selected for pasting
+ */
+ void PasteClipboardItemEvent();
+
+ /**
* @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
*/
virtual void GetTargetSize( Vector2& targetSize );