From 60a7f11599aac7412d6db940ce93d03c24cda261 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sat, 24 Aug 2013 20:22:36 -0400 Subject: [PATCH] Menu: Handle Keyboard input better. When you push an arrow key obscure the cursor so that it doesn't get in the way of the menu items. BeOS R5 also did this. When you select an item with Enter or Space, or cancel with Escape, set the super menu to close in _QuitTracking() if you've specified onlyThis == false. Also, show the cursor here in case you haven't moved the mouse since it was obscured. This fixes a problem where when you select an item in a menu via the keyboard while your mouse is over the parent menu item or menu field it would pop the menu back up again even though you've made your selection or cancelled. --- src/kits/interface/Menu.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 64483cb12a..202bd00f08 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -2646,6 +2647,11 @@ BMenu::_SelectNextItem(BMenuItem* item, bool forward) _SelectItem(nextItem, dynamic_cast(this) != NULL); + if (LockLooper()) { + be_app->ObscureCursor(); + UnlockLooper(); + } + return true; } @@ -2986,9 +2992,19 @@ BMenu::_QuitTracking(bool onlyThis) fState = MENU_STATE_CLOSED; - // Close the whole menu hierarchy - if (!onlyThis && _IsStickyMode()) - _SetStickyMode(false); + if (!onlyThis) { + // Close the whole menu hierarchy + if (Supermenu() != NULL) + Supermenu()->fState = MENU_STATE_CLOSED; + + if (_IsStickyMode()) + _SetStickyMode(false); + + if (LockLooper()) { + be_app->ShowCursor(); + UnlockLooper(); + } + } _Hide(); }