// EXTERNAL INCLUDES
#include <dali/public-api/object/base-object.h>
-
+#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
namespace Dali
{
bool SetItem(const std::string &itemData);
/**
- * @copydoc Dali::Clipboard::GetItem()
+ * @copydoc Dali::Clipboard::RequestItem()
*/
- std::string GetItem( unsigned int index );
+ void RequestItem();
/**
* @copydoc Dali::Clipboard::NumberOfClipboardItems()
*/
void HideClipboard();
+ /**
+ * @copydoc Dali::Clipboard::IsVisible()
+ */
+ bool IsVisible() const;
private:
Clipboard( const Clipboard& );
Clipboard& operator=( Clipboard& );
static Dali::Clipboard mToolkitClipboard;
+ bool mVisible;
+ std::string mItem;
+ int mCount;
}; // class clipboard
Dali::Clipboard Dali::Internal::Adaptor::Clipboard::mToolkitClipboard;
-Clipboard::Clipboard( /*Ecore_X_Window ecoreXwin*/)
+Clipboard::Clipboard()
{
+ mVisible = false;
+ mCount = 0;
}
Clipboard::~Clipboard()
bool Clipboard::SetItem(const std::string &itemData )
{
+ mItem = itemData;
+ mCount = 1;
return true;
}
-std::string Clipboard::GetItem( unsigned int index )
+void Clipboard::RequestItem()
{
- return "";
+ Dali::ClipboardEventNotifier clipboardEventNotifier(Dali::ClipboardEventNotifier::Get());
+ if ( clipboardEventNotifier )
+ {
+ clipboardEventNotifier.SetContent( mItem );
+ clipboardEventNotifier.EmitContentSelectedSignal();
+ }
}
unsigned int Clipboard::NumberOfItems()
{
- return 0;
+ return mCount;
}
void Clipboard::ShowClipboard()
{
+ mVisible = true;
}
void Clipboard::HideClipboard()
{
+ mVisible = false;
}
+bool Clipboard::IsVisible() const
+{
+ return mVisible;
+}
} // namespace Adaptor
return GetImplementation(*this).SetItem( itemData );
}
-std::string Clipboard::GetItem( unsigned int index )
+void Clipboard::RequestItem()
{
- return GetImplementation(*this).GetItem( index );
+ GetImplementation(*this).RequestItem();
}
unsigned int Clipboard::NumberOfItems()
GetImplementation(*this).HideClipboard();
}
+bool Clipboard::IsVisible() const
+{
+ return GetImplementation(*this).IsVisible();
+}
+
} // namespace Dali
bool SetItem( const std::string& itemData );
/**
- * Retreive the string at the given index in the clip board.
- * @param[in] index item in clipboard list to retrieve
- * @return string the text item at the current index.
+ * Request clipboard service to retrieve an item
*/
- std::string GetItem( unsigned int index );
+ void RequestItem();
/**
* Returns the number of item currently in the clipboard
*/
void HideClipboard();
+ /**
+ * @brief Retrieves the clipboard's visibility
+ * @return bool true if the clipboard is visible.
+ */
+ bool IsVisible() const;
+
};
} // namespace Dali
#include <unistd.h>
#include <dali/public-api/rendering/renderer.h>
+#include <dali/devel-api/adaptor-framework/clipboard.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/tap-gesture-event.h>
#include <dali-toolkit-test-suite-utils.h>
application.SendNotification();
application.Render();
+ // Send some taps and check text controller with clipboard window
+ Dali::Clipboard clipboard = Clipboard::Get();
+ clipboard.ShowClipboard();
+ application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+ application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+ clipboard.HideClipboard();
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
// Tap first to get the focus.
application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
#include <dali/integration-api/events/long-press-gesture-event.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include "toolkit-clipboard.h"
using namespace Dali;
using namespace Toolkit;
return time;
}
+Dali::Integration::Point GetPointDownInside( Vector2& pos )
+{
+ Dali::Integration::Point point;
+ point.SetState( PointState::DOWN );
+ point.SetScreenPosition( pos );
+ return point;
+}
+
+Dali::Integration::Point GetPointUpInside( Vector2& pos )
+{
+ Dali::Integration::Point point;
+ point.SetState( PointState::UP );
+ point.SetScreenPosition( pos );
+ return point;
+}
+
struct CallbackFunctor
{
CallbackFunctor(bool* callbackFlag)
ToolkitTestApplication application;
tet_infoline(" utcDaliTextFieldEvent08");
+ Dali::Clipboard clipboard = Clipboard::Get();
+ clipboard.SetItem("testTextFieldEvent");
+
// Checks Longpress when only place holder text
TextField field = TextField::New();
application.SendNotification();
application.Render();
+ Wait(application, 500);
+
+ Stage stage = Stage::GetCurrent();
+ Layer layer = stage.GetRootLayer();
+ Actor actor = layer.FindChildByName("optionPaste");
+
+ if (actor)
+ {
+ Vector3 worldPosition = actor.GetCurrentWorldPosition();
+ Vector2 halfStageSize = stage.GetSize() / 2.0f;
+ Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
+
+ Dali::Integration::TouchEvent event;
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside( position ) );
+ application.ProcessEvent( event );
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside( position ) );
+ application.ProcessEvent( event );
+ }
+ DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
END_TEST;
}
ChangeState( EventData::EDITING );
}
-void Controller::Impl::GetTextFromClipboard( unsigned int itemIndex, std::string& retrievedString )
+void Controller::Impl::RequestGetTextFromClipboard()
{
if ( mClipboard )
{
- retrievedString = mClipboard.GetItem( itemIndex );
+ mClipboard.RequestItem();
}
}
mEventData->mDecorator->SetHighlightActive( false );
mEventData->mDecorator->SetPopupActive( false );
mEventData->mDecoratorUpdated = true;
- HideClipboard();
break;
}
case EventData::INTERRUPTED:
mEventData->mDecorator->SetHighlightActive( false );
mEventData->mDecorator->SetPopupActive( false );
mEventData->mDecoratorUpdated = true;
- HideClipboard();
break;
}
case EventData::SELECTING:
mEventData->mDecorator->SetPopupActive( false );
}
mEventData->mDecoratorUpdated = true;
- HideClipboard();
break;
}
case EventData::EDITING_WITH_POPUP:
SetPopupButtons();
mEventData->mDecorator->SetPopupActive( true );
}
- HideClipboard();
mEventData->mDecoratorUpdated = true;
break;
}
mEventData->mDecorator->SetPopupActive( false );
}
mEventData->mDecoratorUpdated = true;
- HideClipboard();
break;
}
case EventData::SELECTION_HANDLE_PANNING:
SetPopupButtons();
mEventData->mDecorator->SetPopupActive( true );
}
- HideClipboard();
mEventData->mDecoratorUpdated = true;
break;
}
return !result; // If NumberOfItems greater than 0, return false
}
+ bool IsClipboardVisible()
+ {
+ bool result( mClipboard && mClipboard.IsVisible() );
+ return result;
+ }
+
/**
* @brief Calculates the start character index of the first paragraph to be updated and
* the end character index of the last paragraph to be updated.
void SendSelectionToClipboard( bool deleteAfterSending );
- void GetTextFromClipboard( unsigned int itemIndex, std::string& retrievedString );
+ void RequestGetTextFromClipboard();
void RepositionSelectionHandles();
void RepositionSelectionHandles( float visualX, float visualY );
if( NULL != mImpl->mEventData )
{
DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState );
+ EventData::State state( mImpl->mEventData->mState );
+ bool relayoutNeeded( false ); // to avoid unnecessary relayouts when tapping an empty text-field
- if( 1u == tapCount )
+ if( mImpl->IsClipboardVisible() )
{
- // This is to avoid unnecessary relayouts when tapping an empty text-field
- bool relayoutNeeded( false );
-
- if( ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) ||
- ( EventData::EDITING_WITH_PASTE_POPUP == mImpl->mEventData->mState ) )
+ if( EventData::INACTIVE == state || EventData::EDITING == state)
+ {
+ mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
+ }
+ relayoutNeeded = true;
+ }
+ else if( 1u == tapCount )
+ {
+ if( EventData::EDITING_WITH_POPUP == state || EventData::EDITING_WITH_PASTE_POPUP == state )
{
mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE ); // If Popup shown hide it here so can be shown again if required.
}
- if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != mImpl->mEventData->mState ) )
+ if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != state ) )
{
- // Already in an active state so show a popup
- if( !mImpl->IsClipboardEmpty() )
- {
- // Shows Paste popup but could show full popup with Selection options. ( EDITING_WITH_POPUP )
- mImpl->ChangeState( EventData::EDITING_WITH_PASTE_POPUP );
- }
- else
- {
- // Show cursor and grabhandle on first tap, this matches the behaviour of tapping when already editing
- mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
- }
+ mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
relayoutNeeded = true;
}
else
ResetText();
}
- if( EventData::INACTIVE == mImpl->mEventData->mState )
+ if( EventData::INACTIVE == state )
{
mImpl->ChangeState( EventData::EDITING );
}
}
relayoutNeeded = true;
}
-
- // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
- if( relayoutNeeded )
- {
- Event event( Event::TAP_EVENT );
- event.p1.mUint = tapCount;
- event.p2.mFloat = x;
- event.p3.mFloat = y;
- mImpl->mEventData->mEventQueue.push_back( event );
-
- mImpl->RequestRelayout();
- }
}
else if( 2u == tapCount )
{
SelectEvent( x, y, false );
}
}
+ // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
+ if( relayoutNeeded )
+ {
+ Event event( Event::TAP_EVENT );
+ event.p1.mUint = tapCount;
+ event.p2.mFloat = x;
+ event.p3.mFloat = y;
+ mImpl->mEventData->mEventQueue.push_back( event );
+
+ mImpl->RequestRelayout();
+ }
}
// Reset keyboard as tap event has occurred.
mImpl->RequestRelayout();
}
- else
+ else if( !mImpl->IsClipboardVisible() )
{
// Reset the imf manger to commit the pre-edit before selecting the text.
mImpl->ResetImfManager();
}
case Toolkit::TextSelectionPopup::PASTE:
{
- std::string stringToPaste("");
- mImpl->GetTextFromClipboard( 0, stringToPaste ); // Paste latest item from system clipboard
- PasteText( stringToPaste );
+ mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
break;
}
case Toolkit::TextSelectionPopup::SELECT: