Ticket #4930: menu-keyboard-nav.patch
File menu-keyboard-nav.patch, 3.1 KB (added by , 14 years ago) |
---|
-
src/kits/interface/Menu.cpp
221 221 fIgnoreHidden(true), 222 222 fTriggerEnabled(true), 223 223 fRedrawAfterSticky(false), 224 fAttachAborted(false) 224 fAttachAborted(false), 225 fKeyDown(false) 225 226 { 226 227 _InitData(NULL); 227 228 } … … 255 256 fIgnoreHidden(true), 256 257 fTriggerEnabled(true), 257 258 fRedrawAfterSticky(false), 258 fAttachAborted(false) 259 fAttachAborted(false), 260 fKeyDown(false) 259 261 { 260 262 _InitData(NULL); 261 263 } … … 290 292 fIgnoreHidden(true), 291 293 fTriggerEnabled(true), 292 294 fRedrawAfterSticky(false), 293 fAttachAborted(false) 295 fAttachAborted(false), 296 fKeyDown(false) 294 297 { 295 298 _InitData(archive); 296 299 } … … 479 482 void 480 483 BMenu::KeyDown(const char* bytes, int32 numBytes) 481 484 { 485 // maybe ignore key presses if not sticky? 486 fKeyDown = false; 487 // if a menu is still attaching it should abort as the user pressed 488 // another key 489 482 490 // TODO: Test how it works on beos and implement it correctly 483 491 switch (bytes[0]) { 484 492 case B_UP_ARROW: … … 515 523 _SelectNextItem(fSelected, true); 516 524 else { 517 525 if (fSelected && fSelected->Submenu()) { 526 fSelected->Submenu()->_SetStickyMode(true); 527 // fix me: this shouldn't be needed but dynamic menus 528 // aren't getting it set correctly when keyboard 529 // navigating, which aborts the attach 530 fKeyDown = true; 531 // see _OkToProceed() 518 532 _SelectItem(fSelected, true, true); 519 533 } else if (dynamic_cast<BMenuBar*>(Supermenu())) { 520 534 // if we have no submenu and we're an … … 569 583 break; 570 584 } 571 585 } 586 fKeyDown = false; 587 // if a submenu was opened it has failed or suceeded by now 572 588 } 573 589 574 590 … … 1272 1288 fIgnoreHidden(true), 1273 1289 fTriggerEnabled(true), 1274 1290 fRedrawAfterSticky(false), 1275 fAttachAborted(false) 1291 fAttachAborted(false), 1292 fKeyDown(false) 1276 1293 { 1277 1294 _InitData(NULL); 1278 1295 } … … 2742 2759 // BeOS seems to do something similar. This could also be a bug in 2743 2760 // Deskbar, though. 2744 2761 if ((buttons != 0 && stickyMode) 2745 || ((dynamic_cast<BMenuBar*>(this) == NULL 2746 && (buttons == 0 && !stickyMode)) || _HitTestItems(where) != item)) 2762 || (dynamic_cast<BMenuBar*>(this) == NULL 2763 && (buttons == 0 && !stickyMode)) 2764 || ((_HitTestItems(where) != item) && !fKeyDown)) 2747 2765 return false; 2748 2749 2766 return true; 2750 2767 } 2751 2768 -
headers/os/interface/Menu.h
212 212 void _ComputeColumnLayout(int32 index, bool bestFit, 213 213 bool moveItems, BRect& outRect); 214 214 void _ComputeRowLayout(int32 index, bool bestFit, 215 bool moveItems, BRect& outRect); 215 bool moveItems, BRect& outRect); 216 216 void _ComputeMatrixLayout(BRect& outRect); 217 217 218 218 BRect _CalcFrame(BPoint where, bool* scrollOn); … … 291 291 bool fTriggerEnabled; 292 292 bool fRedrawAfterSticky; 293 293 bool fAttachAborted; 294 bool fKeyDown; 294 295 }; 295 296 296 297 #endif // _MENU_H