Esempio n. 1
2
 def keyPressEvent(self, event):
     """Handle key press events"""
     if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
         if self.add_current_text_if_valid():
             self.selected()
     else:
         QComboBox.keyPressEvent(self, event)
Esempio n. 2
0
 def keyPressEvent(self, e):
     """
     Called on key press
     """
     if e.key() == Qt.Key_Return:
         self.EnterPressed.emit()
     QComboBox.keyPressEvent(self, e)
Esempio n. 3
0
 def keyPressEvent(self, event):
     """Handle key press events"""
     if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
         if self.add_current_text_if_valid():
             self.selected()
     else:
         QComboBox.keyPressEvent(self, event)
Esempio n. 4
0
 def keyPressEvent(self, event):
     """Handle key press events"""
     if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
         if self.is_valid():
             self.selected()
             QComboBox.keyPressEvent(self, event) # Insert item in combo box
     else:
         QComboBox.keyPressEvent(self, event)
Esempio n. 5
0
 def keyPressEvent(self, event):
     """Handle key press events"""
     if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
         if self.is_valid():
             self.selected()
             QComboBox.keyPressEvent(self,
                                     event)  # Insert item in combo box
     else:
         QComboBox.keyPressEvent(self, event)
Esempio n. 6
0
 def keyPressEvent(self, event):
     """Handle key press events"""
     if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
         text = self.currentText()
         valid = self.is_valid(text)
         if valid or valid is None:
             self.add_text(text)
             self.selected()
     else:
         QComboBox.keyPressEvent(self, event)
Esempio n. 7
0
 def keyPressEvent(self, event):
     """Handle key press events"""
     if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
         text = self.currentText()
         valid = self.is_valid(text)
         if valid or valid is None:
             self.parent().refresh(text, force=True)
             self.set_default_style()
     else:
         QComboBox.keyPressEvent(self, event)
Esempio n. 8
0
 def keyPressEvent(self, event):
     """Handle key press events"""
     if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
         text = self.currentText()
         valid = self.is_valid(text)
         if valid or valid is None:
             self.parent().refresh(text, force=True)
             self.set_default_style()
     else:
         QComboBox.keyPressEvent(self, event)
 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.emit(SIGNAL("activated(int)"), self.currentIndex())
         self.emit(SIGNAL("activated(const QString &)"), 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.emit(SIGNAL("activated(int)"), self.currentIndex())
         self.emit(SIGNAL("activated(const QString &)"), self.currentText())
         e.accept()
         return
     if not self.isEditable() and len(e.text()) > 0:
         key = unicode(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 = filter(lambda x: x > self.currentIndex(), indexlist)[0]
                 self.setCurrentIndex(i)
             self.emit(SIGNAL("activated(int)"), self.currentIndex())
             self.emit(SIGNAL("activated(const QString &)"),
                       self.currentText())
         e.accept()
         return
     QComboBox.keyPressEvent(self, e)
Esempio n. 10
0
 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.emit(SIGNAL("activated(int)"),self.currentIndex())
         self.emit(SIGNAL("activated(const QString &)"),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.emit(SIGNAL("activated(int)"),self.currentIndex())
         self.emit(SIGNAL("activated(const QString &)"),self.currentText())
         e.accept()
         return
     if not self.isEditable() and len(e.text()) > 0:
         key = unicode(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 = filter(lambda x: x > self.currentIndex(), indexlist)[0]
                 self.setCurrentIndex(i)
             self.emit(SIGNAL("activated(int)"),self.currentIndex())
             self.emit(SIGNAL("activated(const QString &)"),self.currentText())
         e.accept()
         return
     QComboBox.keyPressEvent(self, e)
Esempio n. 11
0
 def keyPressEvent(self, event):
     QComboBox.keyPressEvent(self, event)
     if event.key() == Qt.Key_Return:
         self.emit(SIGNAL("returnPressed()"))
Esempio n. 12
0
 def keyPressEvent(self,event):
     QComboBox.keyPressEvent(self,event)
     if event.key()==Qt.Key_Return:
         self.emit(SIGNAL("returnPressed()"))
Esempio n. 13
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Escape:
         self.clearSelection()
     QComboBox.keyPressEvent(self, event)
Esempio n. 14
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Escape:
         self.clearSelection()
     QComboBox.keyPressEvent(self, event)