X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-field-impl.cpp;h=f4726f76382b4510ae4b6d68b5fb9bb6c732ee02;hp=345865f9cca9b3055a9c3dff9cfcfc5f2c2ea4a4;hb=60d99d04d7677a1b91d4f2fdd9e74bc5e1b5e7bf;hpb=01c086f17e2af89f6c6b1bd30a0240da2fda1e75 diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 345865f..f4726f7 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -133,6 +134,8 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandlePopup", DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "textBackground", VECTOR4, BACKGROUND ) DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextField, "selectedText", STRING, SELECTED_TEXT ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextStart", INTEGER, SELECTED_TEXT_START ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED ) @@ -805,6 +808,26 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: + { + if( impl.mController ) + { + uint32_t start = static_cast(value.Get< int >()); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start ); + impl.SetTextSelectionRange( &start, nullptr ); + } + break; + } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_END: + { + if( impl.mController ) + { + uint32_t end = static_cast(value.Get< int >()); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end ); + impl.SetTextSelectionRange( nullptr, &end ); + } + break; + } } // switch } // textfield } @@ -1228,6 +1251,18 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: + { + Uint32Pair range = impl.GetTextSelectionRange( ); + value = static_cast(range.first); + break; + } + case Toolkit::DevelTextField::Property::SELECTED_TEXT_END: + { + Uint32Pair range = impl.GetTextSelectionRange( ); + value = static_cast(range.second); + break; + } } //switch } @@ -1252,6 +1287,26 @@ void TextField::SelectNone() } } +void TextField::SetTextSelectionRange(const uint32_t *start, const uint32_t *end) +{ + if( mController && mController->IsShowingRealText() ) + { + mController->SetTextSelectionRange( start, end ); + SetKeyInputFocus(); + } +} + +Uint32Pair TextField::GetTextSelectionRange() const +{ + Uint32Pair range; + if( mController && mController->IsShowingRealText() ) + { + range = mController->GetTextSelectionRange(); + } + return range; +} + + InputMethodContext TextField::GetInputMethodContext() { return mInputMethodContext; @@ -1304,7 +1359,7 @@ void TextField::OnInitialize() { Actor self = Self(); - mController = Text::Controller::New( this, this ); + mController = Text::Controller::New( this, this ,this); // When using the vector-based rendering, the size of the GLyphs are different TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH; @@ -1338,10 +1393,10 @@ void TextField::OnInitialize() mController->SetLayoutDirection( layoutDirection ); // Forward input events to controller - EnableGestureDetection( static_cast( Gesture::Tap | Gesture::Pan | Gesture::LongPress ) ); + EnableGestureDetection( static_cast( GestureType::TAP | GestureType::PAN | GestureType::LONG_PRESS ) ); GetTapGestureDetector().SetMaximumTapsRequired( 2 ); - self.TouchSignal().Connect( this, &TextField::OnTouched ); + self.TouchedSignal().Connect( this, &TextField::OnTouched ); // Set BoundingBox to stage size if not already set. Rect boundingBox; @@ -1433,7 +1488,15 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container ) Vector2 contentSize( size.x - ( padding.start + padding.end ), size.y - ( padding.top + padding.bottom ) ); // Support Right-To-Left of padding - Dali::LayoutDirection::Type layoutDirection = static_cast( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + Dali::LayoutDirection::Type layoutDirection; + if( mController->IsMatchSystemLanguageDirection() ) + { + layoutDirection = static_cast( DevelWindow::Get( self ).GetRootLayer().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + } + else + { + layoutDirection = static_cast( self.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + } if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection ) { std::swap( padding.start, padding.end ); @@ -1654,14 +1717,15 @@ void TextField::OnTap( const TapGesture& gesture ) // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures Extents padding; padding = Self().GetProperty( Toolkit::Control::Property::PADDING ); - mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top ); + const Vector2& localPoint = gesture.GetLocalPoint(); + mController->TapEvent( gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top ); SetKeyInputFocus(); } void TextField::OnPan( const PanGesture& gesture ) { - mController->PanEvent( gesture.state, gesture.displacement ); + mController->PanEvent( gesture.GetState(), gesture.GetDisplacement() ); } void TextField::OnLongPress( const LongPressGesture& gesture ) @@ -1672,7 +1736,8 @@ void TextField::OnLongPress( const LongPressGesture& gesture ) } Extents padding; padding = Self().GetProperty( Toolkit::Control::Property::PADDING ); - mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top ); + const Vector2& localPoint = gesture.GetLocalPoint(); + mController->LongPressEvent( gesture.GetState(), localPoint.x - padding.start, localPoint.y - padding.top ); SetKeyInputFocus(); } @@ -1684,7 +1749,7 @@ bool TextField::OnKeyEvent( const KeyEvent& event ) if( Dali::DALI_KEY_ESCAPE == event.GetKeyCode() && mController->ShouldClearFocusOnEscape() ) { // Make sure ClearKeyInputFocus when only key is up - if( event.GetState() == KeyEvent::Up ) + if( event.GetState() == KeyEvent::UP ) { ClearKeyInputFocus(); }