{
"config":
{
- "alwaysShowFocus":false
+ "alwaysShowFocus":false,
+ "clearFocusOnEscape":true
},
"constants":
{
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
+#include <dali/integration-api/events/key-event-integ.h>
using namespace Dali;
using namespace Dali::Toolkit;
END_TEST;
}
+
+
+int UtcDaliStyleManagerConfigSectionTest(void)
+{
+ tet_infoline("Test that the properties in config section are works" );
+
+ const char* defaultTheme =
+ "{\n"
+ " \"config\":\n"
+ " {\n"
+ " \"alwaysShowFocus\":false,\n"
+ " \"clearFocusOnEscape\":false\n"
+ " },\n"
+ " \"styles\":\n"
+ " {\n"
+ " }\n"
+ "}\n";
+
+ Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", defaultTheme );
+
+ ToolkitTestApplication application;
+
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+
+ Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
+ bool alwaysShowFocus = config["alwaysShowFocus"].Get<bool>();
+ DALI_TEST_CHECK( !alwaysShowFocus );
+ bool clearFocusOnEscape = config["clearFocusOnEscape"].Get<bool>();
+ DALI_TEST_CHECK( !clearFocusOnEscape );
+
+ // For coverage
+ Toolkit::TextEditor editor = Toolkit::TextEditor::New();
+ editor.SetKeyboardFocusable( true );
+ Stage::GetCurrent().Add( editor );
+
+ Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
+
+ application.ProcessEvent( Integration::KeyEvent( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", DevelDevice::Class::NONE, DevelDevice::Subclass::NONE ) );
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
- if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this
+ if( Dali::DALI_KEY_ESCAPE == event.keyCode && mController->ShouldClearFocusOnEscape() )
{
// Make sure ClearKeyInputFocus when only key is up
if( event.state == KeyEvent::Up )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyEvent %p keyCode %d\n", mController.Get(), event.keyCode );
- if( Dali::DALI_KEY_ESCAPE == event.keyCode ) // Make a Dali key code for this
+ if( Dali::DALI_KEY_ESCAPE == event.keyCode && mController->ShouldClearFocusOnEscape() )
{
// Make sure ClearKeyInputFocus when only key is up
if( event.state == KeyEvent::Up )
#include <dali-toolkit/internal/text/text-controller.h>
#include <dali-toolkit/internal/text/text-model.h>
#include <dali-toolkit/internal/text/text-view.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
namespace Dali
{
mAutoScrollDirectionRTL( false ),
mUnderlineSetByString( false ),
mShadowSetByString( false ),
- mFontStyleSetByString( false )
+ mFontStyleSetByString( false ),
+ mShouldClearFocusOnEscape( true )
{
mModel = Model::New();
// Set the text properties to default
mModel->mVisualModel->SetUnderlineEnabled( false );
mModel->mVisualModel->SetUnderlineHeight( 0.0f );
+
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ if( styleManager )
+ {
+ bool temp;
+ Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
+ if( config["clearFocusOnEscape"].Get( temp ) )
+ {
+ mShouldClearFocusOnEscape = temp;
+ }
+ }
}
~Impl()
bool mUnderlineSetByString:1; ///< Set when underline is set by string (legacy) instead of map
bool mShadowSetByString:1; ///< Set when shadow is set by string (legacy) instead of map
bool mFontStyleSetByString:1; ///< Set when font style is set by string (legacy) instead of map
+ bool mShouldClearFocusOnEscape:1; ///< Whether text control should clear key input focus
};
} // namespace Text
// Do nothing.
return false;
}
- else if( Dali::DALI_KEY_ESCAPE == keyCode )
+ else if( Dali::DALI_KEY_ESCAPE == keyCode || Dali::DALI_KEY_BACK == keyCode )
{
- // Escape key is a special case which causes focus loss
- KeyboardFocusLostEvent();
-
- // Will request for relayout.
- relayoutNeeded = true;
+ // Do nothing
+ return false;
}
else if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode ) ||
( Dali::DALI_KEY_CURSOR_RIGHT == keyCode ) ||
mImpl->mControlInterface = controlInterface;
}
+bool Controller::ShouldClearFocusOnEscape() const
+{
+ return mImpl->mShouldClearFocusOnEscape;
+}
+
// private : Private contructors & copy operator.
Controller::Controller()
*/
void PasteClipboardItemEvent();
+ /**
+ * @brief Return true when text control should clear key input focus when escape key is pressed.
+ *
+ * @return Whether text control should clear key input focus or not when escape key is pressed.
+ */
+ bool ShouldClearFocusOnEscape() const;
+
protected: // Inherit from Text::Decorator::ControllerInterface.
/**
{
"config":
{
- "alwaysShowFocus":false
+ "alwaysShowFocus":false,
+ "clearFocusOnEscape":false
},
"styles":
{
{
"config":
{
- "alwaysShowFocus":false
+ "alwaysShowFocus":false,
+ "clearFocusOnEscape":true
},
"styles":
{
{
"config":
{
- "alwaysShowFocus":false
+ "alwaysShowFocus":false,
+ "clearFocusOnEscape":true
},
"styles":
{