MCPcopy Create free account
hub / github.com/NetHack/NetHack / keyPressEvent

Method keyPressEvent

win/Qt/qt_menu.cpp:653–706  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653void NetHackQtMenuWindow::keyPressEvent(QKeyEvent *key_event)
654{
655 uchar key = keyValue(key_event);
656 if (!key)
657 return;
658
659 // only one possible match for key==ch, and if one occurs it takes
660 // precedence over any other match (for instance, some menus might
661 // contain '-' to represent bare hands vs '-' for menu_unselect_page,
662 // or ':' to look into a container vs ':' for menu_search)
663 for (int row = 0; row < itemcount; ++row)
664 if (key == (uchar) itemlist[row].ch) {
665 ToggleSelect(row, false);
666 return;
667 }
668
669 if (key == '\033') {
670 if (counting)
671 ClearCount();
672 else if (searching)
673 ClearSearch();
674 else
675 reject();
676 } else if (key == '\r' || key == '\n' || key == ' ') {
677 accept();
678 } else if ('0' <= key && key <= '9' && !counting) {
679 // check whether digit 'key' matches a group accelerator
680 int hits = 0;
681 for (int row = 0; row < itemcount; ++row)
682 if (key == (uchar) itemlist[row].gch) {
683 ToggleSelect(row, false); // matched so toggle this item
684 ++hits;
685 }
686 if (!hits) // didn't match any group accelerator; start a count
687 InputCount(key);
688 } else if (('0' <= key && key <= '9')
689 || (key == '#' && !counting)
690 || key == '\b' || key == '\177') {
691 InputCount(key);
692 } else if (key == MENU_SELECT_ALL || key == MENU_SELECT_PAGE) {
693 All();
694 } else if (key == MENU_INVERT_ALL || key == MENU_INVERT_PAGE) {
695 Invert();
696 } else if (key == MENU_UNSELECT_ALL || key == MENU_UNSELECT_PAGE) {
697 ChooseNone();
698 } else if (key == MENU_SEARCH) {
699 Search();
700 } else {
701 // multiple matches are possible with gch
702 for (int row = 0; row < itemcount; ++row)
703 if (key == (uchar) itemlist[row].gch)
704 ToggleSelect(row, false);
705 }
706}
707
708void NetHackQtMenuWindow::All()
709{

Callers

nothing calls this directly

Calls 1

keyValueFunction · 0.85

Tested by

no test coverage detected