]> granicus.if.org Git - nethack/commitdiff
Qt popup dialog input vs '&'
authorPatR <rankin@nethack.org>
Mon, 26 Oct 2020 19:44:40 +0000 (12:44 -0700)
committerPatR <rankin@nethack.org>
Mon, 26 Oct 2020 19:44:40 +0000 (12:44 -0700)
I'm not sure whether any yn_function() calls include ampersand
in the list of acceptable choices but if any did, the button
for that character would have shown up blank.  (Clicking on it
would have successfully produced '&' as player's input though.)

doc/fixes37.0
win/Qt/qt_yndlg.cpp

index d56d5c7b69911444510b1e4f383822a22d5ce60b..38ebeb41a575c319613c09ca475b2c2c7142332e 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.341 $ $NHDT-Date: 1603666043 2020/10/25 22:47:23 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.342 $ $NHDT-Date: 1603741470 2020/10/26 19:44:30 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -458,6 +458,7 @@ Qt: rename toolbar button "Get" and action menu choice "Get" to "Pick up"
 Qt: status icons for alignment|hunger|encumbrance which started out centered
        relative to the label text below them would shift to being left
        justified when status got updated
+Qt: handle '&' properly if it occurs as part of yn_function popup dialog
 Qt+OSX: fix control key
 Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
        'O' command to "Game->Run-time options" and entry "Game->Qt settings"
index d7b370a3283473b9a33724f3d9e226ecedfd60fc..4ea3688b0c1f5f7fe2635e715adf9f3295fec7b2 100644 (file)
@@ -246,6 +246,17 @@ char NetHackQtYnDialog::Exec()
                 case '\033': // won't happen; ESC is hidden
                     button_name = "Esc";
                     break;
+                case '&':
+                    // ampersand is used as a hidden quote char to flag
+                    // next character as a keyboard shortcut associated
+                    // with the current action--that's inappropriate here;
+                    // two consecutive ampersands are needed to display
+                    // one in a button label; first check whether caller
+                    // has already done that, skip this one if so
+                    if (i > 0 && ch[i - 1].cell() == QChar('&'))
+                        continue; // next i
+                    button_name = "&&";
+                    break;
                 }
             }
             button=new QPushButton(button_name);