aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-07-03 12:47:22 (GMT)
committerfluxgen <fluxgen>2003-07-03 12:47:22 (GMT)
commit8890bfe94688fdcc7c22f99a6725f6030a98a71f (patch)
tree9f50f0d6213c85e916f62358dfbf23c58d4eb00a /src/FbTk
parentb4aba1ff12e455cb5fb6f76dee93f405bfe5738e (diff)
downloadfluxbox-8890bfe94688fdcc7c22f99a6725f6030a98a71f.zip
fluxbox-8890bfe94688fdcc7c22f99a6725f6030a98a71f.tar.bz2
using left to close submenu and right to open it
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Menu.cc94
1 files changed, 31 insertions, 63 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 75ead42..67ec949 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.cc,v 1.26 2003/07/03 12:23:28 fluxgen Exp $ 25// $Id: Menu.cc,v 1.27 2003/07/03 12:47:22 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -320,11 +320,6 @@ void Menu::nextItem() {
320 else 320 else
321 drawItem(which_press, true, true, true); 321 drawItem(which_press, true, true, true);
322 322
323#ifdef DEBUG
324 cerr<<__FILE__<<"("<<__FUNCTION__<<")"<<endl;
325 cerr<<"which_press = "<<which_press<<endl;
326#endif // DEBUG
327
328} 323}
329 324
330void Menu::prevItem() { 325void Menu::prevItem() {
@@ -354,11 +349,33 @@ void Menu::prevItem() {
354 drawItem(which_press, true, true, true); 349 drawItem(which_press, true, true, true);
355 } 350 }
356 351
357#ifdef DEBUG 352}
358 cerr<<__FILE__<<"("<<__FUNCTION__<<")"<<endl; 353
359 cerr<<"which_press = "<<which_press<<endl; 354void Menu::enterSubmenu() {
360#endif // DEBUG 355 if (which_press < 0 || which_press >= menuitems.size())
356 return;
357
358 Menu *submenu = menuitems[which_press]->submenu();
359 if (submenu == 0)
360 return;
361 361
362 submenu->grabInputFocus();
363 submenu->which_press = -1; // so we land on 0 after nextItem()
364 submenu->nextItem();
365}
366
367void Menu::enterParent() {
368 if (which_press < 0 || which_press >= menuitems.size() || parent() == 0)
369 return;
370
371 Menu *submenu = menuitems[which_press]->submenu();
372 if (submenu)
373 submenu->menu.window.hide();
374
375 drawItem(which_press, false, true, true);
376 which_press = -1; // dont select any in this
377 // return focus to parent but keep this window open
378 parent()->grabInputFocus();
362} 379}
363 380
364void Menu::disableTitle() { 381void Menu::disableTitle() {
@@ -1259,33 +1276,6 @@ void Menu::leaveNotifyEvent(XCrossingEvent &ce) {
1259 } 1276 }
1260} 1277}
1261 1278
1262void Menu::enterSubmenu() {
1263 if (which_press < 0 || which_press >= menuitems.size())
1264 return;
1265
1266 Menu *submenu = menuitems[which_press]->submenu();
1267 if (submenu == 0)
1268 return;
1269
1270 submenu->grabInputFocus();
1271 submenu->which_press = -1; // so we land on 0 after nextItem()
1272 submenu->nextItem();
1273}
1274
1275void Menu::enterParent() {
1276 if (which_press < 0 || which_press >= menuitems.size() || parent() == 0)
1277 return;
1278
1279 Menu *submenu = menuitems[which_press]->submenu();
1280 if (submenu)
1281 submenu->menu.window.hide();
1282
1283 drawItem(which_press, false, true, true);
1284 which_press = -1; // dont select any in this
1285 // return focus to parent but keep this window open
1286 parent()->grabInputFocus();
1287}
1288
1289void Menu::keyPressEvent(XKeyEvent &event) { 1279void Menu::keyPressEvent(XKeyEvent &event) {
1290 KeySym ks; 1280 KeySym ks;
1291 char keychar[1]; 1281 char keychar[1];
@@ -1303,33 +1293,11 @@ void Menu::keyPressEvent(XKeyEvent &event) {
1303 case XK_Down: 1293 case XK_Down:
1304 nextItem(); 1294 nextItem();
1305 break; 1295 break;
1306 case XK_Left: // enter submenu or leave this menu and enter parent 1296 case XK_Left: // enter parent if we have one
1307 // if we have a submenu we should determine if 1297 enterParent();
1308 // we should open it or close this and enter parent depending on which
1309 // side the parent is.
1310 // if parent on the left -> enter parent
1311 // if parent on the right -> enter submenu of this item
1312 if (which_press >= 0 && which_press < menuitems.size()) {
1313 Menu *submenu = menuitems[which_press]->submenu();
1314 if (parent() && parent()->x() < x()) // parent on the left
1315 enterParent();
1316 else if (submenu) // else parent on the right and submenu on the left
1317 enterSubmenu();
1318 }
1319 break; 1298 break;
1320 case XK_Right: // enter submenu or leave this menu and enter parent 1299 case XK_Right: // enter submenu if we have one
1321 // if we have a submenu we should determine if 1300 enterSubmenu();
1322 // we should open it or close this and enter parent depending on which
1323 // side the parent is.
1324 // if parent on the left -> enter submenu of this item
1325 // parent on the right -> leave this menu and enter parent
1326 if (which_press >= 0 && which_press < menuitems.size()) {
1327 Menu *submenu = menuitems[which_press]->submenu();
1328 if (parent() && parent()->x() > x()) // parent on the right
1329 enterParent();
1330 else if (submenu) // else parent on the left and submenu on the right
1331 enterSubmenu();
1332 }
1333 break; 1301 break;
1334 case XK_Escape: // close menu 1302 case XK_Escape: // close menu
1335 hide(); 1303 hide();