From 6061c0fb5d3b725f254af4f7b04b5042d2bd3d9b Mon Sep 17 00:00:00 2001 From: Yuri Chebotarev Date: Thu, 3 Dec 2009 13:47:52 +0200 Subject: fix for EXT-1190 Accordion should support keyboard accessability --HG-- branch : product-engine --- indra/llui/llflatlistview.cpp | 96 ++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 33 deletions(-) (limited to 'indra/llui/llflatlistview.cpp') diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index f4a5f1c990..d4c3cfb7b6 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -689,6 +689,17 @@ LLRect LLFlatListView::getSelectedItemsRect() return rc; } +void LLFlatListView::selectFirstItem () +{ + selectItemPair(mItemPairs.front(), true); +} + +void LLFlatListView::selectLastItem () +{ + selectItemPair(mItemPairs.back(), true); +} + + // virtual bool LLFlatListView::selectNextItemPair(bool is_up_direction, bool reset_selection) { @@ -696,53 +707,53 @@ bool LLFlatListView::selectNextItemPair(bool is_up_direction, bool reset_selecti if ( !mItemPairs.size() ) return false; - item_pair_t* cur_sel_pair = NULL; + item_pair_t* to_sel_pair = NULL; - + item_pair_t* cur_sel_pair = NULL; if ( mSelectedItemPairs.size() ) { // Take the last selected pair cur_sel_pair = mSelectedItemPairs.back(); - } - else - { - // If there weren't selected items then choose the first one bases on given direction - cur_sel_pair = (is_up_direction) ? mItemPairs.back() : mItemPairs.front(); - // Force selection to first item - to_sel_pair = cur_sel_pair; - } - - // Bases on given direction choose next item to select - if ( is_up_direction ) - { - // Find current selected item position in mItemPairs list - pairs_list_t::reverse_iterator sel_it = std::find(mItemPairs.rbegin(), mItemPairs.rend(), cur_sel_pair); - - for (;++sel_it != mItemPairs.rend();) + // Bases on given direction choose next item to select + if ( is_up_direction ) { - // skip invisible items - if ( (*sel_it)->first->getVisible() ) + // Find current selected item position in mItemPairs list + pairs_list_t::reverse_iterator sel_it = std::find(mItemPairs.rbegin(), mItemPairs.rend(), cur_sel_pair); + + for (;++sel_it != mItemPairs.rend();) { - to_sel_pair = *sel_it; - break; + // skip invisible items + if ( (*sel_it)->first->getVisible() ) + { + to_sel_pair = *sel_it; + break; + } } } - } - else - { - // Find current selected item position in mItemPairs list - pairs_list_t::iterator sel_it = std::find(mItemPairs.begin(), mItemPairs.end(), cur_sel_pair); - - for (;++sel_it != mItemPairs.end();) + else { - // skip invisible items - if ( (*sel_it)->first->getVisible() ) + // Find current selected item position in mItemPairs list + pairs_list_t::iterator sel_it = std::find(mItemPairs.begin(), mItemPairs.end(), cur_sel_pair); + + for (;++sel_it != mItemPairs.end();) { - to_sel_pair = *sel_it; - break; + // skip invisible items + if ( (*sel_it)->first->getVisible() ) + { + to_sel_pair = *sel_it; + break; + } } } } + else + { + // If there weren't selected items then choose the first one bases on given direction + cur_sel_pair = (is_up_direction) ? mItemPairs.back() : mItemPairs.front(); + // Force selection to first item + to_sel_pair = cur_sel_pair; + } + if ( to_sel_pair ) { @@ -920,4 +931,23 @@ void LLFlatListView::onFocusLost() mSelectedItemsBorder->setVisible(FALSE); } +//virtual +void LLFlatListView::notify(const LLSD& info) +{ + if(info.has("action")) + { + std::string str_action = info["action"]; + if(str_action == "select_first") + { + setFocus(true); + selectFirstItem(); + } + else if(str_action == "select_last") + { + setFocus(true); + selectLastItem(); + } + } +} + //EOF -- cgit v1.2.3