From: Adeel Kazmi Date: Wed, 15 Mar 2017 14:35:27 +0000 (-0700) Subject: Merge "Implement scroll bar in the TextEditor" into devel/master X-Git-Tag: dali_1.2.31~4 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=660728e83fd72194f53642fd74c09db561f88496;hp=b480cf8f1604782bc3104e1b170e73a27c9d351b Merge "Implement scroll bar in the TextEditor" into devel/master --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index e410fb1..aee8e65 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -105,6 +105,10 @@ const float SCROLL_SPEED = 300.f; const unsigned int DEFAULT_FONT_SIZE = 1152u; const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); +const int KEY_A_CODE = 38; +const int KEY_D_CODE = 40; +const int KEY_WHITE_SPACE_CODE = 65; + static bool gTextChangedCallBackCalled; static bool gInputStyleChangedCallbackCalled; static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask; @@ -683,7 +687,7 @@ int utcDaliTextEditorTextChangedP(void) editor.SetKeyInputFocus(); gTextChangedCallBackCalled = false; - application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) ); DALI_TEST_CHECK( gTextChangedCallBackCalled ); END_TEST; @@ -1085,7 +1089,7 @@ int utcDaliTextEditorInputStyleChanged02(void) editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" ); editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1193,7 +1197,7 @@ int utcDaliTextEditorEvent01(void) application.Render(); // Add a key event but as the text editor has not the focus it should do nothing. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1210,8 +1214,8 @@ int utcDaliTextEditorEvent01(void) application.Render(); // Now the text editor has the focus, so it can handle the key events. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1242,8 +1246,8 @@ int utcDaliTextEditorEvent01(void) application.Render(); // The second text editor has the focus. It should handle the key events. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1299,8 +1303,8 @@ int utcDaliTextEditorEvent02(void) DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION ); // Now the text editor has the focus, so it can handle the key events. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1514,7 +1518,7 @@ int utcDaliTextEditorEvent04(void) } // Add a character - application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1541,7 +1545,7 @@ int utcDaliTextEditorEvent04(void) } // Add a character - application.ProcessEvent( GenerateKey( " ", " ", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1601,7 +1605,7 @@ int utcDaliTextEditorEvent05(void) for( unsigned int index = 0u; index < 10u; ++index ) { // Add a character - application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index a4b3c70..f551dad 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -111,6 +111,9 @@ const float SCROLL_SPEED = 300.f; const unsigned int DEFAULT_FONT_SIZE = 1152u; const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); +const int KEY_A_CODE = 38; +const int KEY_D_CODE = 40; + static bool gTextChangedCallBackCalled; static bool gMaxCharactersCallBackCalled; static bool gInputStyleChangedCallbackCalled; @@ -851,7 +854,7 @@ int utcDaliTextFieldTextChangedP(void) field.SetKeyInputFocus(); gTextChangedCallBackCalled = false; - application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down ) ); DALI_TEST_CHECK( gTextChangedCallBackCalled ); END_TEST; @@ -904,8 +907,8 @@ int utcDaliTextFieldMaxCharactersReachedP(void) gMaxCharactersCallBackCalled = false; - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); DALI_TEST_CHECK( gMaxCharactersCallBackCalled ); DALI_TEST_CHECK( maxLengthReachedSignal ); @@ -936,8 +939,8 @@ int utcDaliTextFieldMaxCharactersReachedN(void) gMaxCharactersCallBackCalled = false; - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); DALI_TEST_CHECK( !gMaxCharactersCallBackCalled ); DALI_TEST_CHECK( !maxLengthReachedSignal ); @@ -1402,7 +1405,7 @@ int utcDaliTextFieldEvent01(void) application.Render(); // Add a key event but as the text field has not the focus it should do nothing. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1419,8 +1422,8 @@ int utcDaliTextFieldEvent01(void) application.Render(); // Now the text field has the focus, so it can handle the key events. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1451,8 +1454,8 @@ int utcDaliTextFieldEvent01(void) application.Render(); // The second text field has the focus. It should handle the key events. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); @@ -1510,8 +1513,8 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION ); // Now the text field has the focus, so it can handle the key events. - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); - application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); + application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 047eb4b..4eb5662 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1719,8 +1719,15 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) int keyCode = keyEvent.keyCode; const std::string& keyString = keyEvent.keyPressed; + const bool isNullKey = ( 0 == keyCode ) && ( keyString.empty() ); + // Pre-process to separate modifying events from non-modifying input events. - if( Dali::DALI_KEY_ESCAPE == keyCode ) + if( isNullKey ) + { + // In some platforms arrive key events with no key code. + // Do nothing. + } + else if( Dali::DALI_KEY_ESCAPE == keyCode ) { // Escape key is a special case which causes focus loss KeyboardFocusLostEvent(); @@ -1790,6 +1797,7 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) && ( mImpl->mEventData->mState != EventData::INACTIVE ) && + ( !isNullKey ) && ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) ) { // Should not change the state if the key is the shift send by the imf manager.