def keyPressEvent(self, event): self.lastKey = event.key() if event.key() == QtCore.Qt.Key_Enter or \ event.key() == QtCore.Qt.Key_Return or\ event.key() == QtCore.Qt.Key_Tab: if self.proximoWidget: self.proximoWidget.setFocus() QComboBox.keyPressEvent(self, event)
def keyPressEvent(self, e): key = e.key() mod = e.modifiers() if key == Qt.Key_Down or key == Qt.Key_Up: if not mod: QApplication.sendEvent(self.parent(), e) return elif mod == Qt.AltModifier: self.showPopup() QComboBox.keyPressEvent(self, e)
def keyPressEvent(self, e): key = e.key() mod = e.modifiers() if key == Qt.Key_Down or key == Qt.Key_Up: if not mod: QApplication.sendEvent( self.parent(), e ) return elif mod == Qt.AltModifier: self.showPopup() QComboBox.keyPressEvent(self, e)
def keyPressEvent(self, e): keycode = e.key() if keycode == Qt.Key_Up and (e.modifiers() == Qt.NoModifier or e.modifiers() == Qt.KeypadModifier ) and self.currentIndex() > 0: self.setCurrentIndex(self.currentIndex() - 1) self.activated[int].emit(self.currentIndex()) self.activated[str].emit(self.currentText()) e.accept() return if keycode == Qt.Key_Down and ( e.modifiers() == Qt.NoModifier or e.modifiers() == Qt.KeypadModifier ) and self.currentIndex() < self.count() - 1: self.setCurrentIndex(self.currentIndex() + 1) self.activated[int].emit(self.currentIndex()) self.activated[str].emit(self.currentText()) e.accept() return if not self.isEditable() and len(e.text()) > 0: key = str(e.text()).upper() indexlist = [] if len(key) == 1: itemkeys = self.buildItemKeys() for i in range(0, len(itemkeys)): if key in itemkeys[i]: indexlist.append(i) if len(indexlist): if self.currentIndex() >= indexlist[-1]: self.setCurrentIndex(indexlist[0]) else: i = [x for x in indexlist if x > self.currentIndex()][0] self.setCurrentIndex(i) self.activated[int].emit(self.currentIndex()) self.activated[str].emit(self.currentText()) e.accept() return QComboBox.keyPressEvent(self, e)
def keyPressEvent(self, event, forwarded=False): self._processing_key = True from PyQt5.QtCore import Qt from PyQt5.QtGui import QKeySequence if session.ui.key_intercepted(event.key()): return want_focus = forwarded and event.key() not in [ Qt.Key_Control, Qt.Key_Shift, Qt.Key_Meta, Qt.Key_Alt ] import sys control_key = Qt.MetaModifier if sys.platform == "darwin" else Qt.ControlModifier shifted = event.modifiers() & Qt.ShiftModifier if event.key() == Qt.Key_Up: # up arrow self.tool.history_dialog.up(shifted) elif event.key() == Qt.Key_Down: # down arrow self.tool.history_dialog.down(shifted) elif event.matches(QKeySequence.Undo): want_focus = False session.undo.undo() elif event.matches(QKeySequence.Redo): want_focus = False session.undo.redo() elif event.modifiers() & control_key: if event.key() == Qt.Key_N: self.tool.history_dialog.down(shifted) elif event.key() == Qt.Key_P: self.tool.history_dialog.up(shifted) elif event.key() == Qt.Key_U: self.tool.cmd_clear() self.tool.history_dialog.search_reset() elif event.key() == Qt.Key_K: self.tool.cmd_clear_to_end_of_line() self.tool.history_dialog.search_reset() else: QComboBox.keyPressEvent(self, event) else: QComboBox.keyPressEvent(self, event) if want_focus: # Give command line the focus, so that up/down arrow work as # expected rather than changing the selection level self.setFocus() self._processing_key = False
def on_filter_combo_box_key_pressed(self, event): """Checks if enter is pressed on filterEdit""" key = event.key() if key in (Qt.Key_Return, Qt.Key_Enter): self.on_filter_btn_clicked() QComboBox.keyPressEvent(self.filter_combo_box, event)
def keyPressEvent(self, e): if e.key() == Qt.Key_Return: self.runAction() else: QComboBox.keyPressEvent(self, e)
def keyPressEvent(self, event): if event.key() == Qt.Key_Escape: self.clearSelection() QComboBox.keyPressEvent(self, event)