const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
+ const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
static bool gTextChangedCallBackCalled;
static bool gInputStyleChangedCallbackCalled;
+ static bool gMaxCharactersCallBackCalled;
static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
struct CallbackFunctor
gInputStyleMask = mask;
}
+ static void TestMaxLengthReachedCallback( TextEditor control )
+ {
+ tet_infoline(" TestMaxLengthReachedCallback");
+
+ gMaxCharactersCallBackCalled = true;
+ }
+
// Generate a KeyEvent to send to Core.
Integration::KeyEvent GenerateKey( const std::string& keyName,
const std::string& logicalKey,
END_TEST;
}
+int UtcDaliTextEditorMoveConstructor(void)
+{
+ ToolkitTestApplication application;
+
+ TextEditor textEditor = TextEditor::New();
+ textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
+ DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
+
+ TextEditor moved = std::move( textEditor );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
+ DALI_TEST_CHECK( !textEditor );
+
+ END_TEST;
+}
+
int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
{
ToolkitTestApplication application;
END_TEST;
}
+int UtcDaliTextEditorMoveAssignment(void)
+{
+ ToolkitTestApplication application;
+
+ TextEditor textEditor = TextEditor::New();
+ textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
+ DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
+
+ TextEditor moved;
+ moved = std::move( textEditor );
+ DALI_TEST_CHECK( moved );
+ DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+ DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
+ DALI_TEST_CHECK( !textEditor );
+
+ END_TEST;
+}
+
int UtcDaliTextEditorNewP(void)
{
ToolkitTestApplication application;
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
+ DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
END_TEST;
}
END_TEST;
}
+
+ int utcDaliTextEditorMaxCharactersReached(void)
+ {
+ ToolkitTestApplication application;
+ tet_infoline("utcDaliTextEditorMaxCharactersReached");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK( editor );
+
+ application.GetScene().Add( editor );
+
+ const int maxNumberOfCharacters = 1;
+ editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
+ DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
+
+ editor.SetKeyInputFocus();
+
+ // connect to the text changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
+ bool maxLengthReachedSignal = false;
+ editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
+
+ gMaxCharactersCallBackCalled = false;
+
+ application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+ application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
+ DALI_TEST_CHECK( maxLengthReachedSignal );
+
+ END_TEST;
+ }
#include <dali-toolkit/devel-api/text/rendering-backend.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
- #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/text/text-enumerations-impl.h>
#include <dali-toolkit/internal/text/rendering/text-backend.h>
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "matchSystemLanguageDirection", BOOLEAN, MATCH_SYSTEM_LANGUAGE_DIRECTION )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "renderingBackend", INTEGER, RENDERING_BACKEND )
+ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "maxLength", INTEGER, MAX_LENGTH )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
+ DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
DALI_TYPE_REGISTRATION_END()
}
break;
}
+ case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
+ {
+ if( impl.mController )
+ {
+ const int max = value.Get< int >();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p MAX_LENGTH %d\n", impl.mController.Get(), max );
+
+ impl.mController->SetMaximumNumberOfCharacters( max );
+ }
+ break;
+ }
} // switch
} // texteditor
}
}
break;
}
+ case Toolkit::DevelTextEditor::Property::MAX_LENGTH:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->GetMaximumNumberOfCharacters();
+ }
+ break;
+ }
} //switch
}
return mInputMethodContext;
}
+ DevelTextEditor::MaxLengthReachedSignalType& TextEditor::MaxLengthReachedSignal()
+ {
+ return mMaxLengthReachedSignal;
+ }
+
bool TextEditor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
Dali::BaseHandle handle( object );
{
editor.InputStyleChangedSignal().Connect( tracker, functor );
}
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_MAX_LENGTH_REACHED ) )
+ {
+ if( editor )
+ {
+ Internal::TextEditor& editorImpl( GetImpl( editor ) );
+ editorImpl.MaxLengthReachedSignal().Connect( tracker, functor );
+ }
+ }
else
{
// signalName does not match any signal
// Fill-parent area by default
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
- self.OnStageSignal().Connect( this, &TextEditor::OnStageConnect );
+ self.OnSceneSignal().Connect( this, &TextEditor::OnSceneConnect );
DevelControl::SetInputMethodContext( *this, mInputMethodContext );
void TextEditor::MaxLengthReached()
{
- // Nothing to do as TextEditor doesn't emit a max length reached signal.
+ Dali::Toolkit::TextEditor handle( GetOwner() );
+ mMaxLengthReachedSignal.Emit( handle );
}
void TextEditor::InputStyleChanged( Text::InputStyle::Mask inputStyleMask )
}
}
-void TextEditor::OnStageConnect( Dali::Actor actor )
+void TextEditor::OnSceneConnect( Dali::Actor actor )
{
if ( mHasBeenStaged )
{
}
}
-void TextEditor::OnStageConnection( int depth )
+void TextEditor::OnSceneConnection( int depth )
{
// Sets the depth to the visuals inside the text's decorator.
mDecorator->SetTextDepth( depth );
// The depth of the text renderer is set in the RenderText() called from OnRelayout().
- // Call the Control::OnStageConnection() to set the depth of the background.
- Control::OnStageConnection( depth );
+ // Call the Control::OnSceneConnection() to set the depth of the background.
+ Control::OnSceneConnection( depth );
}
bool TextEditor::OnTouched( Actor actor, const TouchData& touch )
{
- return true;
+ return false;
}
void TextEditor::OnIdleSignal()
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/devel-api/controls/scroll-bar/scroll-bar.h>
#include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
+ #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
#include <dali-toolkit/internal/text/decorator/text-decorator.h>
#include <dali-toolkit/internal/text/text-control-interface.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
InputMethodContext GetInputMethodContext();
/**
+ * @copydoc Dali::Toollkit::TextEditor::MaxLengthReachedSignal()
+ */
+ DevelTextEditor::MaxLengthReachedSignalType& MaxLengthReachedSignal();
+
+ /**
* Connects a callback function with the object's signals.
* @param[in] object The object providing the signal.
* @param[in] tracker Used to disconnect the signal.
virtual void OnLongPress( const LongPressGesture& gesture );
/**
- * @copydoc Control::OnStageConnection()
+ * @copydoc Control::OnSceneConnection()
*/
- virtual void OnStageConnection( int depth );
+ virtual void OnSceneConnection( int depth );
/**
* @copydoc Dali::CustomActorImpl::OnKeyEvent(const KeyEvent&)
*/
void RenderText( Text::Controller::UpdateTextType updateTextType );
- // Connection needed to re-render text, when a text editor returns to the stage.
- void OnStageConnect( Dali::Actor actor );
+ // Connection needed to re-render text, when a text editor returns to the scene.
+ void OnSceneConnect( Dali::Actor actor );
private: // Data
// Signals
Toolkit::TextEditor::TextChangedSignalType mTextChangedSignal;
Toolkit::TextEditor::InputStyleChangedSignalType mInputStyleChangedSignal;
Toolkit::TextEditor::ScrollStateChangedSignalType mScrollStateChangedSignal;
+ Toolkit::DevelTextEditor::MaxLengthReachedSignalType mMaxLengthReachedSignal;
InputMethodContext mInputMethodContext;
Text::ControllerPtr mController;