changeset 17980:05b65e0b8d6f

Fix cycling in menu with hidden items. Thanks again to Jonas Jermann for the report.
author albeu
date Mon, 27 Mar 2006 19:27:42 +0000
parents 392c7c1b8ccc
children 368ad4d775be
files libmenu/menu_list.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmenu/menu_list.c	Mon Mar 27 18:33:23 2006 +0000
+++ b/libmenu/menu_list.c	Mon Mar 27 19:27:42 2006 +0000
@@ -135,21 +135,25 @@
 void menu_list_read_cmd(menu_t* menu,int cmd) {
   switch(cmd) {
   case MENU_CMD_UP:
-    if(!mpriv->current->prev) {
-      for( ; mpriv->current->next != NULL ; mpriv->current = mpriv->current->next)
-	/* NOTHING */;
+    while(mpriv->current->prev) {
+      mpriv->current = mpriv->current->prev;
       if(!mpriv->current->hide) return;
     }
+    for( ; mpriv->current->next != NULL ; mpriv->current = mpriv->current->next)
+      /* NOTHING */;
+    if(!mpriv->current->hide) return;
     while(mpriv->current->prev) {
       mpriv->current = mpriv->current->prev;
       if(!mpriv->current->hide) return;
     }
     break;
   case MENU_CMD_DOWN:
-    if(!mpriv->current->next) {
-      mpriv->current = mpriv->menu;
+    while(mpriv->current->next) {
+      mpriv->current = mpriv->current->next;
       if(!mpriv->current->hide) return;
     }
+    mpriv->current = mpriv->menu;
+    if(!mpriv->current->hide) return;
     while(mpriv->current->next) {
       mpriv->current = mpriv->current->next;
       if(!mpriv->current->hide) return;