diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2009-08-08 17:20:45 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2009-08-08 17:20:45 (GMT) |
commit | ca9e2e0d15bc9958959c4636018a3c7384c81157 (patch) | |
tree | 3970474710b886d5f5679f2c81444c5ee7eed843 /src/FbTk | |
parent | 07da360b2be4a96e82de80d25b0506d58ea8124e (diff) | |
download | fluxbox_lack-ca9e2e0d15bc9958959c4636018a3c7384c81157.zip fluxbox_lack-ca9e2e0d15bc9958959c4636018a3c7384c81157.tar.bz2 |
allow navigating multi-column menus with left and right arrows
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/Menu.cc | 25 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 2 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 7cf2ac9..4489d0f 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -328,9 +328,11 @@ void Menu::cycleItems(bool reverse) { | |||
328 | new_index = vec[i]->getIndex(); | 328 | new_index = vec[i]->getIndex(); |
329 | } | 329 | } |
330 | 330 | ||
331 | if (new_index == -1) | 331 | if (new_index != -1) |
332 | return; | 332 | setActiveIndex(new_index); |
333 | } | ||
333 | 334 | ||
335 | void Menu::setActiveIndex(int new_index) { | ||
334 | // clear the items and close any open submenus | 336 | // clear the items and close any open submenus |
335 | int old_active_index = m_active_index; | 337 | int old_active_index = m_active_index; |
336 | m_active_index = new_index; | 338 | m_active_index = new_index; |
@@ -1065,11 +1067,26 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1065 | break; | 1067 | break; |
1066 | case XK_Left: // enter parent if we have one | 1068 | case XK_Left: // enter parent if we have one |
1067 | resetTypeAhead(); | 1069 | resetTypeAhead(); |
1068 | internal_hide(); | 1070 | if (menu.sublevels > 1 && m_active_index >= menu.persub) { |
1071 | int new_index = m_active_index - menu.persub; | ||
1072 | while (new_index >= 0 && !isItemEnabled(new_index)) | ||
1073 | new_index -= menu.persub; | ||
1074 | if (new_index >= 0) | ||
1075 | setActiveIndex(new_index); | ||
1076 | } else | ||
1077 | internal_hide(); | ||
1069 | break; | 1078 | break; |
1070 | case XK_Right: // enter submenu if we have one | 1079 | case XK_Right: // enter submenu if we have one |
1071 | resetTypeAhead(); | 1080 | resetTypeAhead(); |
1072 | enterSubmenu(); | 1081 | if (menu.sublevels > 1 && validIndex(m_active_index) && |
1082 | validIndex(m_active_index + menu.persub)) { | ||
1083 | int new_index = m_active_index + menu.persub; | ||
1084 | while (validIndex(new_index) && !isItemEnabled(new_index)) | ||
1085 | new_index += menu.persub; | ||
1086 | if (validIndex(new_index)) | ||
1087 | setActiveIndex(new_index); | ||
1088 | } else | ||
1089 | enterSubmenu(); | ||
1073 | break; | 1090 | break; |
1074 | case XK_Escape: // close menu | 1091 | case XK_Escape: // close menu |
1075 | m_type_ahead.reset(); | 1092 | m_type_ahead.reset(); |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 519a78b..4eb5e27 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -83,6 +83,8 @@ public: | |||
83 | virtual void lower(); | 83 | virtual void lower(); |
84 | /// cycle through menuitems | 84 | /// cycle through menuitems |
85 | void cycleItems(bool reverse); | 85 | void cycleItems(bool reverse); |
86 | /// set and highlight new active index | ||
87 | void setActiveIndex(int new_index); | ||
86 | void enterSubmenu(); | 88 | void enterSubmenu(); |
87 | 89 | ||
88 | void disableTitle(); | 90 | void disableTitle(); |