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.
This commit is contained in:
John Scipione
2013-08-25 00:17:41 -04:00
parent 3dd9ff2b5d
commit 60a7f11599
+19 -3
View File
@@ -17,6 +17,7 @@
#include <ctype.h>
#include <string.h>
#include <Application.h>
#include <Bitmap.h>
#include <ControlLook.h>
#include <Debug.h>
@@ -2646,6 +2647,11 @@ BMenu::_SelectNextItem(BMenuItem* item, bool forward)
_SelectItem(nextItem, dynamic_cast<BMenuBar*>(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();
}