def contextMenuEvent(self, event): """Context menu of tab options. """ tab_index = self.tabBar().tabAt(event.pos()) tab_menu = None # Currently over a tab if tab_index > -1: #rename_action = QAction("Rename", self) #rename_action.triggered.connect(self._setNewTabName(tab_index)) remove_tab_action = QAction( QIcon(os.path.join('images', 'edit-delete.png')), "Close", self) remove_tab_action.triggered.connect( self._removeSelectedTab(tab_index)) tab_menu = QMenu(self) #tab_menu.addAction(rename_action) tab_menu.addSeparator() tab_menu.addAction(remove_tab_action) if tab_index == 0: remove_tab_action.setDisabled(True) # In tab bar, but not over any tabs else: new_page_action = QAction("Insert New Page", self) new_page_action.triggered.connect(self.newPage) tab_menu = QMenu(self) tab_menu.addAction(new_page_action) tab_menu.exec_(event.globalPos()) self.focusInEvent(QFocusEvent(QEvent.FocusIn))
def toggleHighlightertoggleOption(self): """A super long named method that simply turns on/off the edit menu highlighting toggle.""" self._parent._turn_OnOff_high_action.toggle() # Fix bug observed in Qt 5.2.1 on *buntu 14.04 LTS where: # 1. The cursor remains invisible after closing the context menu # 2. Keyboard input causes it to appear, but it doesn't blink # 3. Switching focus away from and back to the window fixes it self.focusInEvent(QFocusEvent(QEvent.FocusIn))
def contextMenuEvent(self, event): clear_text = QAction("Clear Defintion") clear_text.triggered.connect(self.clear) popup_menu = self.createStandardContextMenu(event.pos()) popup_menu.addSeparator() popup_menu.addAction(clear_text) if not len(self.toPlainText()): clear_text.setDisabled(True) popup_menu.exec_(event.globalPos()) self.focusInEvent(QFocusEvent(QEvent.FocusIn))
def contextMenuEvent(self, event): """Custom context menu handler to add a spelling suggestions submenu.""" popup_menu = self.createSpellcheckContextMenu(event.pos()) popup_menu.exec_(event.globalPos()) # Fix bug observed in Qt 5.2.1 on *buntu 14.04 LTS where: # 1. The cursor remains invisible after closing the context menu # 2. Keyboard input causes it to appear, but it doesn't blink # 3. Switching focus away from and back to the window fixes it self.focusInEvent(QFocusEvent(QEvent.FocusIn))
def on_focus_event(self, wl_view, type_): event = QFocusEvent(FOCUS_EVENTS[type_]) self.renderer.sendEvent(event)
def keyPressEvent(self, event): QLineEdit.keyPressEvent(self, event); if (event.key() == Qt.Key_Return): self.focusOutEvent(QFocusEvent( QEvent.FocusOut, Qt.MouseFocusReason))
def focusInEvent(self, event: QFocusEvent): self.renderer.sendEvent(event) event.accept() return True