virtual void TextChanged(bool immediate) = 0;
using immediate, can decide whether we only emit the signal when OnRelayout() is called next time,
otherwise emits it immediately.
* there is a issue that the timing of callback calls has been delayed
due to a recent patch that limits unnecessary callbacks.
(
33ccee79d16a90d5f7ab427de1503ccc5bee4324)
Because of this, there is a problem that the TC like example below fails.
This patch can prevents the following issues.
/* example */
bool textChanged;
...
static void OnTextChanged(TextField control)
{
textChanged = true;
}
...
field.TextChangedSignal().Connect(&OnTextChanged);
textChanged = false;
field.SetProperty(TextField::Property::TEXT, "hello");
DALI_TEST_CHECK(textChanged); // At this point, textChanged is false, so TC Fail occurs.
/* example */
Change-Id: If0a331c56f35eae931b34d128b4fe4282fc686b6
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
gTextChangedCallBackCalled = false;
editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( gTextChangedCallBackCalled );
DALI_TEST_CHECK( textChangedSignal );
+ application.SendNotification();
editor.SetKeyInputFocus();
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( gTextChangedCallBackCalled );
// Remove all text
editor.SetProperty( TextField::Property::TEXT, "" );
- application.SendNotification();
- application.Render();
// Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( !gTextChangedCallBackCalled );
// Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( !gTextChangedCallBackCalled );
END_TEST;
gTextChangedCallBackCalled = false;
field.SetProperty( TextField::Property::TEXT, "ABC" );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( gTextChangedCallBackCalled );
DALI_TEST_CHECK( textChangedSignal );
+ application.SendNotification();
field.SetKeyInputFocus();
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( gTextChangedCallBackCalled );
// Remove all text
field.SetProperty( TextField::Property::TEXT, "" );
- application.SendNotification();
- application.Render();
// Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( !gTextChangedCallBackCalled );
// Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
gTextChangedCallBackCalled = false;
application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
- application.SendNotification();
- application.Render();
DALI_TEST_CHECK( !gTextChangedCallBackCalled );
END_TEST;
// If there is text changed, callback is called.
if(mTextChanged)
{
- Dali::Toolkit::TextEditor handle(GetOwner());
- mTextChangedSignal.Emit(handle);
- mTextChanged = false;
+ EmitTextChangedSignal();
}
}
}
}
-void TextEditor::TextChanged()
+void TextEditor::TextChanged(bool immediate)
{
- mTextChanged = true;
+ if(immediate) // Emits TextChangedSignal immediately
+ {
+ EmitTextChangedSignal();
+ }
+ else
+ {
+ mTextChanged = true;
+ }
+}
+
+void TextEditor::EmitTextChangedSignal()
+{
+ Dali::Toolkit::TextEditor handle(GetOwner());
+ mTextChangedSignal.Emit(handle);
+ mTextChanged = false;
}
void TextEditor::MaxLengthReached()
/**
* @copydoc Text::EditableControlInterface::TextChanged()
*/
- void TextChanged() override;
+ void TextChanged(bool immediate) override;
/**
* @copydoc Text::EditableControlInterface::MaxLengthReached()
*/
void OnIdleSignal();
+ /**
+ * @brief Emits TextChanged signal.
+ */
+ void EmitTextChangedSignal();
+
/**
* @brief set RenderActor's position with new scrollPosition
*
bool mScrollAnimationEnabled : 1;
bool mScrollBarEnabled : 1;
bool mScrollStarted : 1;
- bool mTextChanged : 1;
+ bool mTextChanged : 1; ///< If true, emits TextChangedSignal in next OnRelayout().
struct AccessibleImpl : public DevelControl::AccessibleImpl,
public virtual Dali::Accessibility::Text,
// If there is text changed, callback is called.
if(mTextChanged)
{
- Dali::Toolkit::TextField handle(GetOwner());
- mTextChangedSignal.Emit(handle);
- mTextChanged = false;
+ EmitTextChangedSignal();
}
}
}
}
-void TextField::TextChanged()
+void TextField::TextChanged(bool immediate)
{
- mTextChanged = true;
+ if(immediate) // Emits TextChangedSignal immediately
+ {
+ EmitTextChangedSignal();
+ }
+ else
+ {
+ mTextChanged = true;
+ }
+}
+
+void TextField::EmitTextChangedSignal()
+{
+ Dali::Toolkit::TextField handle(GetOwner());
+ mTextChangedSignal.Emit(handle);
+ mTextChanged = false;
}
void TextField::MaxLengthReached()
/**
* @copydoc Text::EditableControlInterface::TextChanged()
*/
- void TextChanged() override;
+ void TextChanged(bool immediate) override;
/**
* @copydoc Text::EditableControlInterface::MaxLengthReached()
*/
void OnIdleSignal();
+ /**
+ * @brief Emits TextChanged signal.
+ */
+ void EmitTextChangedSignal();
+
/**
* Construct a new TextField.
*/
int mRenderingBackend;
int mExceedPolicy;
bool mHasBeenStaged : 1;
- bool mTextChanged : 1;
+ bool mTextChanged : 1; ///< If true, emits TextChangedSignal in next OnRelayout().
protected:
struct AccessibleImpl : public DevelControl::AccessibleImpl,
(NULL != controller.mImpl->mEditableControlInterface))
{
// Do this last since it provides callbacks into application code
- controller.mImpl->mEditableControlInterface->TextChanged();
+ controller.mImpl->mEditableControlInterface->TextChanged(false);
}
return true;
(NULL != controller.mImpl->mEditableControlInterface))
{
// Do this last since it provides callbacks into application code
- controller.mImpl->mEditableControlInterface->TextChanged();
+ controller.mImpl->mEditableControlInterface->TextChanged(false);
}
return callbackData;
if(NULL != controller.mImpl->mEditableControlInterface)
{
- controller.mImpl->mEditableControlInterface->TextChanged();
+ controller.mImpl->mEditableControlInterface->TextChanged(true);
}
break;
}
// Do this last since it provides callbacks into application code.
if(NULL != impl.mEditableControlInterface)
{
- impl.mEditableControlInterface->TextChanged();
+ impl.mEditableControlInterface->TextChanged(true);
}
}
if(NULL != impl.mEditableControlInterface)
{
// Do this last since it provides callbacks into application code
- impl.mEditableControlInterface->TextChanged();
+ impl.mEditableControlInterface->TextChanged(true);
}
}
/**
* @brief Called to signal that text has been inserted or deleted.
+ *
+ * @param[in] immediate If true, it immediately emits the signal, if false, only emits once the signal when OnRelayout() is called next time.
*/
- virtual void TextChanged() = 0;
+ virtual void TextChanged(bool immediate) = 0;
/**
* @brief Called when the number of characters to be inserted exceeds the maximum limit