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

Method notify

outdated/win/Qt3/qt3_win.cpp:5162–5213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5160}
5161
5162bool NetHackQtBind::notify(QObject *receiver, QEvent *event)
5163{
5164 // Ignore Alt-key navigation to menubar, it's annoying when you
5165 // use Alt-Direction to move around.
5166 if ( main && event->type()==QEvent::KeyRelease && main==receiver
5167 && ((QKeyEvent*)event)->key() == Key_Alt )
5168 return TRUE;
5169
5170 bool result=QApplication::notify(receiver,event);
5171#ifdef SAFERHANGUP
5172 if (program_state.done_hup) {
5173 keybuffer.Put('\033');
5174 qApp->exit_loop();
5175 return TRUE;
5176 }
5177#endif
5178 if (event->type()==QEvent::KeyPress) {
5179 QKeyEvent* key_event=(QKeyEvent*)event;
5180
5181 if (!key_event->isAccepted()) {
5182 const int k=key_event->key();
5183 bool macro=FALSE;
5184 for (int i=0; !macro && key_macro[i].key; i++) {
5185 if (key_macro[i].key==k
5186 && ((key_macro[i].state&key_event->state())==key_macro[i].state))
5187 {
5188 keybuffer.Put(key_macro[i].macro);
5189 macro=TRUE;
5190 }
5191 }
5192 char ch=key_event->ascii();
5193 if ( !ch && (key_event->state() & Qt::ControlButton) ) {
5194 // On Mac, it aint-ncessarily-control
5195 if ( k>=Qt::Key_A && k<=Qt::Key_Z )
5196 ch = k - Qt::Key_A + 1;
5197 }
5198 if (!macro && ch) {
5199 bool alt = (key_event->state()&AltButton) ||
5200 (k >= Key_0 && k <= Key_9 && (key_event->state()&ControlButton));
5201 keybuffer.Put(key_event->key(),ch + (alt ? 128 : 0),
5202 key_event->state());
5203 key_event->accept();
5204 result=TRUE;
5205 }
5206
5207 if (ch || macro) {
5208 qApp->exit_loop();
5209 }
5210 }
5211 }
5212 return result;
5213}
5214
5215NetHackQtBind* NetHackQtBind::instance=0;
5216NetHackQtKeyBuffer NetHackQtBind::keybuffer;

Callers

nothing calls this directly

Calls 1

PutMethod · 0.45

Tested by

no test coverage detected