From 0b6c587dbb2b7c52a832975bf742af70ba7c98b8 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Mon, 13 Mar 2017 11:58:07 +0000 Subject: [PATCH] (Text) Fix bug where we cannot jump to the first line from the start of the second line Change-Id: If9069eb33869f44f6a94ca43e0201dadf6e4154b --- dali-toolkit/internal/text/text-controller-impl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index c54ca22..986c4e5 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1151,8 +1151,9 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event ) } const LineIndex lineIndex = mModel->mVisualModel->GetLineOfCharacter( characterIndex ); + const LineIndex previousLineIndex = ( lineIndex > 0 ? lineIndex - 1u : lineIndex ); - if( lineIndex > 0u ) + if( previousLineIndex >= 0u ) { // Retrieve the cursor position info. CursorInfo cursorInfo; @@ -1160,7 +1161,7 @@ void Controller::Impl::OnCursorKeyEvent( const Event& event ) cursorInfo ); // Get the line above. - const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + ( lineIndex - 1u ) ); + const LineRun& line = *( mModel->mVisualModel->mLines.Begin() + previousLineIndex ); // Get the next hit 'y' point. const float hitPointY = cursorInfo.lineOffset - 0.5f * ( line.ascender - line.descender ); -- 2.7.4