Ticket #7182: menu.diff2

File menu.diff2, 1.9 KB (added by Pete, 13 years ago)

Additional corrections to keyboard navigation (diff)

Line 
1Index: src/kits/interface/Menu.cpp
2===================================================================
3--- src/kits/interface/Menu.cpp (revision 42415)
4+++ src/kits/interface/Menu.cpp (working copy)
5@@ -470,6 +470,13 @@
6 BMenu::KeyDown(const char* bytes, int32 numBytes)
7 {
8 // TODO: Test how it works on beos and implement it correctly
9+ BMenu *supermenu = Supermenu();
10+ if (supermenu != NULL && supermenu->fState == MENU_STATE_TRACKING
11+ && dynamic_cast<BMenuBar*>(supermenu) == NULL) {
12+ BMessenger msgr(supermenu);
13+ msgr.SendMessage(Window()->CurrentMessage());
14+ return;
15+ }
16 switch (bytes[0]) {
17 case B_UP_ARROW:
18 if (fLayout == B_ITEMS_IN_COLUMN)
19@@ -479,7 +486,7 @@
20 case B_DOWN_ARROW:
21 {
22 BMenuBar* bar = dynamic_cast<BMenuBar*>(Supermenu());
23- if (bar != NULL && fState == MENU_STATE_CLOSED) {
24+ if (bar != NULL) {
25 // tell MenuBar's _Track:
26 bar->fState = MENU_STATE_KEY_TO_SUBMENU;
27 }
28@@ -1669,7 +1676,7 @@
29 fState = MENU_STATE_TRACKING;
30 if (!LockLooper())
31 break;
32- } else if (item != NULL) {
33+ } else if (item != NULL && fState <= MENU_STATE_TRACKING_SUBMENU) {
34 _UpdateStateOpenSelect(item, location, navAreaRectAbove,
35 navAreaRectBelow, selectedTime, navigationAreaTime);
36 if (!releasedOnce)
37@@ -1692,12 +1699,13 @@
38 fState = MENU_STATE_TRACKING;
39 }
40
41- if (fSuper != NULL) {
42- // Give supermenu the chance to continue tracking
43- *action = fState;
44- UnlockLooper();
45- return NULL;
46- }
47+ // Seems not needed and to work better without!:
48+// if (fSuper != NULL) {
49+// // Give supermenu the chance to continue tracking
50+// *action = fState;
51+// UnlockLooper();
52+// return NULL;
53+// }
54 }
55
56 UnlockLooper();
57@@ -2614,7 +2622,7 @@
58
59 int32 index = fItems.IndexOf(item);
60 int32 loopCount = numItems;
61- while (--loopCount) {
62+ while (loopCount--) {
63 // Cycle through menu items in the given direction...
64 if (forward)
65 index++;