X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=5d179e195c36c412785a17ec7d731f65856f420d;hb=2aa99730d8c3106deeac1186e057055604835752;hp=5a9f749fd0363b974ee1bfab98c37f37264a4354;hpb=7b555d7c7bd9d3236e251039be950358bf318393;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index 5a9f749..5d179e1 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "graphic.h" #include "list.h" #include "part.h" @@ -234,6 +235,18 @@ void List::render_special(const Part &part, GL::Renderer &renderer) const slider.render(renderer); } +bool List::key_press(unsigned key, unsigned mod) +{ + if(key==Input::KEY_UP && mod==MOD_CTRL) + move_focus(NAV_UP, false); + else if(key==Input::KEY_DOWN && mod==MOD_CTRL) + move_focus(NAV_DOWN, false); + else + return false; + + return true; +} + void List::button_press(int x, int y, unsigned btn) { if(btn==4 || btn==5) @@ -314,6 +327,7 @@ void List::touch_motion(int, int y, unsigned finger) void List::focus_in() { + Container::focus_in(); if(focus_index>=0 && items[focus_index]->is_visible()) set_input_focus(items[focus_index]); else @@ -327,22 +341,31 @@ void List::focus_in() bool List::navigate(Navigation nav) { - if(nav==NAV_UP && !items.empty()) + if((nav==NAV_UP || nav==NAV_DOWN) && !items.empty()) + move_focus(nav, true); + else if(nav==NAV_ACTIVATE) + set_selected_index(focus_index); + else + return false; + + return true; +} + +void List::move_focus(Navigation nav, bool select) +{ + if(nav==NAV_UP) { if(focus_index>0) set_focus_index(focus_index-1); } - else if(nav==NAV_DOWN && !items.empty()) + else if(nav==NAV_DOWN) { if(static_cast(focus_index+1)