//virtual S32 LLFlatListView::notify(const LLSD& info) { if(info.has("action")) { std::string str_action = info["action"]; if(str_action == "select_first") { setFocus(true); selectFirstItem(); return 1; } else if(str_action == "select_last") { setFocus(true); selectLastItem(); return 1; } } else if (info.has("rearrange")) { rearrangeItems(); notifyParentItemsRectChanged(); return 1; } return 0; }
// virtual bool LLFlatListView::selectNextItemPair(bool is_up_direction, bool reset_selection) { // No items - no actions! if ( 0 == size() ) return false; if (!mIsConsecutiveSelection) { // Leave only one item selected if list has not consecutive selection if (mSelectedItemPairs.size() && !reset_selection) { item_pair_t* cur_sel_pair = mSelectedItemPairs.back(); resetSelection(); selectItemPair (cur_sel_pair, true); } } if ( mSelectedItemPairs.size() ) { item_pair_t* to_sel_pair = NULL; item_pair_t* cur_sel_pair = NULL; // Take the last selected pair cur_sel_pair = mSelectedItemPairs.back(); // 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();) { // 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();) { // skip invisible items if ( (*sel_it)->first->getVisible() ) { to_sel_pair = *sel_it; break; } } } if ( to_sel_pair ) { bool select = true; if ( reset_selection ) { // Reset current selection if we were asked about it resetSelection(); } else { // If item already selected and no reset request than we should deselect last selected item. select = (mSelectedItemPairs.end() == std::find(mSelectedItemPairs.begin(), mSelectedItemPairs.end(), to_sel_pair)); } // Select/Deselect next item selectItemPair(select ? to_sel_pair : cur_sel_pair, select); // Mark it as consecutive selection mIsConsecutiveSelection = true; return true; } } else { // If there weren't selected items then choose the first one bases on given direction // Force selection to first item if (is_up_direction) selectLastItem(); else selectFirstItem(); // Mark it as consecutive selection mIsConsecutiveSelection = true; return true; } return false; }