void tvertical_list::handle_key_down_arrow(SDLMod /*modifier*/, bool& handled) { if(get_selected_item_count() == 0) { return; } // NOTE maybe this should only work if we can select only one item... handled = true; for(size_t i = get_ordered_index(get_selected_item()) + 1; i < get_item_count(); ++i) { // why do we do this check here but not in handle_key_up_arrow? if(item_ordered(i).get_visible() == twidget::tvisible::invisible || !get_item_shown(get_item_at_ordered(i))) { continue; } // NOTE we check the first widget to be active since grids have no // active flag. This method might not be entirely reliable. tcontrol* control = dynamic_cast<tcontrol*>(item_ordered(i).widget(0, 0)); if(control && control->get_active()) { select_item(get_item_at_ordered(i), true); return; } } }
void thorizontal_list::handle_key_right_arrow( SDLMod /*modifier*/, bool& handled) { if(get_selected_item_count() == 0) { return; } // NOTE maybe this should only work if we can select only one item... handled = true; for(size_t i = get_selected_item() + 1; i < get_item_count(); ++i) { if(item(i).get_visible() == twidget::INVISIBLE || !get_item_shown(i)) { continue; } // NOTE we check the first widget to be active since grids have no // active flag. This method might not be entirely reliable. tcontrol* control = dynamic_cast<tcontrol*>(item(i).widget(0, 0)); if(control && control->get_active()) { select_item(i); return; } } }
void tvertical_list::handle_key_up_arrow(SDLMod /*modifier*/, bool& handled) { if(get_selected_item_count() == 0) { return; } // NOTE maybe this should only work if we can select only one item... handled = true; for(int i = get_ordered_index(get_selected_item()) - 1; i >= 0; --i) { // NOTE we check the first widget to be active since grids have no // active flag. This method might not be entirely reliable. tcontrol* control = dynamic_cast<tcontrol*>(item_ordered(i).widget(0, 0)); if(control && control->get_active()) { select_item(get_item_at_ordered(i), true); return; } } }