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

Method CheckboxClicked

win/Qt/qt_menu.cpp:886–902  ·  view source on GitHub ↗

checkbox click handler for table cells (*,1); presence of a checkbox in the clicked cell prevents the table cell click handler above from being called even if this handler doesn't get set up

Source from the content-addressed store, hash-verified

884// presence of a checkbox in the clicked cell prevents the table cell click
885// handler above from being called even if this handler doesn't get set up
886void NetHackQtMenuWindow::CheckboxClicked(bool on_off UNUSED)
887{
888 // find which checkbox just got toggled by looking for one whose
889 // check state doesn't match corresponding itemlist[].selected flag
890 // [there's got to be a more direct way of achieving this...]
891 for (int row = 0; row < itemcount; ++row) {
892 // for pick-one menu, ToggleSelect() will return to menu's caller
893 if (itemlist[row].Selectable()) {
894 if (!isSelected(row) ^ !itemlist[row].selected) {
895 // signal dispatcher has already checked or unchecked this box
896 ToggleSelect(row, true);
897 return;
898 }
899 }
900 }
901 // didn't find any changed checkbox; should never happen; what to do?
902}
903
904bool NetHackQtMenuWindow::isSelected(int row)
905{

Callers

nothing calls this directly

Calls 1

SelectableMethod · 0.45

Tested by

no test coverage detected