From: Umar Date: Tue, 13 Dec 2016 18:08:25 +0000 (+0000) Subject: Fix TableView::GetNextKeyboardFocusableActor function by returning a valid actor... X-Git-Tag: dali_1.2.20~17^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=d0216900ef43b4ea9561b88b544c40095ad2a00d Fix TableView::GetNextKeyboardFocusableActor function by returning a valid actor in a given direction. Change-Id: I066dff41dadbfabc556f1a01637951a25821f5d4 --- diff --git a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp index 4a655aa..e3b0334 100644 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp @@ -1319,51 +1319,74 @@ Actor TableView::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolki int numberOfColumns = GetColumns(); int numberOfRows = GetRows(); + bool lastCell = false; + Actor nextValidActor; + switch ( direction ) { case Toolkit::Control::KeyboardFocus::LEFT: { - if(--currentColumn < 0) + do { - currentColumn = numberOfColumns - 1; - if(--currentRow < 0) + if(--currentColumn < 0) { - currentRow = loopEnabled ? numberOfRows - 1 : 0; - focusLost = (currentRow == 0); + currentColumn = numberOfColumns - 1; + if(--currentRow < 0) + { + lastCell = true; + currentRow = loopEnabled ? numberOfRows - 1 : 0; + focusLost = (currentRow == 0); + } } - } + nextValidActor = GetChildAt(Toolkit::TableView::CellPosition(currentRow, currentColumn)); + } while ( !nextValidActor && !lastCell ); break; } case Toolkit::Control::KeyboardFocus::RIGHT: { - if(++currentColumn > numberOfColumns - 1) + do { - currentColumn = 0; - if(++currentRow > numberOfRows - 1) + if(++currentColumn > numberOfColumns - 1) { - currentRow = loopEnabled ? 0 : numberOfRows - 1; - focusLost = (currentRow == numberOfRows - 1); + currentColumn = 0; + if(++currentRow > numberOfRows - 1) + { + lastCell = true; + currentRow = loopEnabled ? 0 : numberOfRows - 1; + focusLost = (currentRow == numberOfRows - 1); + } } - } + nextValidActor = GetChildAt(Toolkit::TableView::CellPosition(currentRow, currentColumn)); + } while ( !nextValidActor && !lastCell ); break; } case Toolkit::Control::KeyboardFocus::UP: { - if(--currentRow < 0) + do { - currentRow = loopEnabled ? numberOfRows - 1 : 0; - focusLost = (currentRow == 0); - } + if(--currentRow < 0) + { + lastCell = true; + currentRow = loopEnabled ? numberOfRows - 1 : 0; + focusLost = (currentRow == 0); + } + nextValidActor = GetChildAt(Toolkit::TableView::CellPosition(currentRow, currentColumn)); + } while ( !nextValidActor && !lastCell ); break; } case Toolkit::Control::KeyboardFocus::DOWN: { - if(++currentRow > numberOfRows - 1) + do { - currentRow = loopEnabled ? 0 : numberOfRows - 1; - focusLost = (currentRow == numberOfRows - 1); - } + if(++currentRow > numberOfRows - 1) + { + lastCell = true; + currentRow = loopEnabled ? 0 : numberOfRows - 1; + focusLost = (currentRow == numberOfRows - 1); + } + nextValidActor = GetChildAt(Toolkit::TableView::CellPosition(currentRow, currentColumn)); + } while ( !nextValidActor && !lastCell ); break; } }