Qt: support digit chars as menu group accelerators
Have Qt catch up with tty and X11: in a menu, when not already entering a count and player types a digit, check whether it is the group accelerator for any of the menu entries. If so, toggle their selection state; if not, begin counting for the next item the player eventually picks.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.0 $ $NHDT-Date: 1643491497 2022/01/29 21:24:57 $
|
||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.782 $ $NHDT-Date: 1644545143 2022/02/11 02:05:43 $
|
||||
|
||||
General Fixes and Modified Features
|
||||
-----------------------------------
|
||||
@@ -1178,6 +1178,9 @@ Qt: force the 'toptenwin' option On so that high scores display at end of game
|
||||
might not be seen (note: doesn't apply to 'nethack -s')
|
||||
Qt: during role/race/&c selection, update role titles with their icons, and
|
||||
also Valk eligibility, when gender is toggled
|
||||
Qt: if a menu of objects contains at least one iron ball, and player is not
|
||||
alreadly in the midst of entering a count, recognize '0' as a group
|
||||
accelerator rather than the start of a count
|
||||
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
|
||||
for instance), clicking on [Search], entering a search target in the
|
||||
resulting popup and clicking on [Okay] or typing <return>, the text
|
||||
|
||||
@@ -378,7 +378,8 @@ void NetHackQtMenuWindow::PadMenuColumns(bool split_descr)
|
||||
QFontMetrics fm(table->font());
|
||||
QString col0width_str = "";
|
||||
if (biggestcount > 0L)
|
||||
col0width_str = QString::asprintf("%*ld", std::max(countdigits, 1), biggestcount);
|
||||
col0width_str = QString::asprintf("%*ld", std::max(countdigits, 1),
|
||||
biggestcount);
|
||||
int col0width_int = (int) fm.QFM_WIDTH(col0width_str) + MENU_WIDTH_SLOP;
|
||||
if (col0width_int > table->columnWidth(0))
|
||||
WidenColumn(0, col0width_int);
|
||||
@@ -464,7 +465,8 @@ void NetHackQtMenuWindow::UpdateCountColumn(long newcount)
|
||||
} else {
|
||||
biggestcount = std::max(biggestcount, newcount);
|
||||
QString num;
|
||||
num = QString::asprintf("%*ld", std::max(countdigits, 1), biggestcount);
|
||||
num = QString::asprintf("%*ld", std::max(countdigits, 1),
|
||||
biggestcount);
|
||||
int numlen = (int) num.length();
|
||||
if (numlen % 2)
|
||||
++numlen;
|
||||
@@ -723,6 +725,16 @@ void NetHackQtMenuWindow::keyPressEvent(QKeyEvent *key_event)
|
||||
reject();
|
||||
} else if (key == '\r' || key == '\n' || key == ' ') {
|
||||
accept();
|
||||
} else if ('0' <= key && key <= '9' && !counting) {
|
||||
// check whether digit 'key' matches a group accelerator
|
||||
int hits = 0;
|
||||
for (int row = 0; row < itemcount; ++row)
|
||||
if (key == (uchar) itemlist[row].gch) {
|
||||
ToggleSelect(row, false); // matched so toggle this item
|
||||
++hits;
|
||||
}
|
||||
if (!hits) // didn't match any group accelerator; start a count
|
||||
InputCount(key);
|
||||
} else if (('0' <= key && key <= '9')
|
||||
|| (key == '#' && !counting)
|
||||
|| key == '\b' || key == '\177') {
|
||||
|
||||
Reference in New Issue
Block a user