summaryrefslogtreecommitdiffstats
path: root/src/intrfn.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-11-09 09:19:27 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2010-11-09 09:19:27 +0100
commitae6fbbd93f457d8a2f016c712302baf97eda550c (patch)
tree0452ce96eaab95985fd6f8aeab16d5c2fa2d8b94 /src/intrfn.c
parenta000515cf668c45ac2c173800dc354cd6b22a470 (diff)
When a key is pressed in a menu, default to the corresponding item.
Diffstat (limited to 'src/intrfn.c')
-rw-r--r--src/intrfn.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/intrfn.c b/src/intrfn.c
index 47d49fe..227ad12 100644
--- a/src/intrfn.c
+++ b/src/intrfn.c
@@ -483,10 +483,15 @@ int wmenuSelect_ext(WINDOW *window, const int yinfo, const int y_org, const int
if(key==PADENTER)
key = menuItems[*current].key;
#endif
-
/* Is pressed key among acceptable ones */
if( key!=0 && (strchr(available, toupper(key))!=NULL || strchr(available, key)!=NULL))
+ {
+ const unsigned int old_current=*current;
+ for(i=0; menuItems[i].key != 0 && menuItems[i].key != key; i++);
+ *current=(menuItems[i].key == 0 ? old_current : i);
break;
+ }
+
/* Should all keys to be accepted? */
if( key && (menuType & MENU_ACCEPT_OTHERS)!=0 ) break;
/* The key has not been accepted so far -> let's reject it */