Qt: ^V on OSX
I can't take credit for this and still have no idea why it is needed, but it fixes use of ^V as a command and as input to to the regular version of yn_function(). In particular, '&' command reports it as ^V. Unfortunately when 'popup_dialog' is set, no control characters seem to be accepted by the part of NetHackQtYnDialog(Exec+KeyPressEvent) responsible for arbitrary input. It also causes getlin() to terminate but I can't think of any situation where ^V would be considered to be valid input for getlin() so won't worry about that. I put it in as '#if MACOSX' because I don't know whether any other Qt platforms need it.
This commit is contained in:
@@ -10,6 +10,8 @@ extern "C" {
|
||||
|
||||
#include "qt_pre.h"
|
||||
#include <QtGui/QtGui>
|
||||
#include <QtWidgets/QShortcut>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtWidgets/QtWidgets>
|
||||
#endif
|
||||
@@ -548,6 +550,13 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
* setMenuRole() can be used to override this behavior.
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef CTRL_V_HACK
|
||||
// NetHackQtBind::notify() sees all control characters except for ^V
|
||||
QShortcut *c_V = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_V), this);
|
||||
connect(c_V, &QShortcut::activated, this, &NetHackQtMainWindow::CtrlV);
|
||||
#endif
|
||||
|
||||
QMenu* game=new QMenu;
|
||||
QMenu* apparel=new QMenu;
|
||||
QMenu* act1=new QMenu;
|
||||
@@ -889,6 +898,20 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CTRL_V_HACK
|
||||
#ifndef C
|
||||
#define C(c) (0x1f & (c))
|
||||
#endif
|
||||
|
||||
// called when ^V is typed while the main window has keyboard focus;
|
||||
// all other control characters go through NetHackQtBind::notify()
|
||||
void NetHackQtMainWindow::CtrlV()
|
||||
{
|
||||
static const char cV[] = { C('V'), '\0' };
|
||||
doKeys(cV);
|
||||
}
|
||||
#endif
|
||||
|
||||
// add a toolbar button to invoke command 'name' via function '(*func)()'
|
||||
void NetHackQtMainWindow::AddToolButton(QToolBar *toolbar, QSignalMapper *sm,
|
||||
const char *name, int NDECL((*func)),
|
||||
|
||||
Reference in New Issue
Block a user