def show_custom_context_menu(self, pos): if self.isReadOnly(): return menu = QTextEdit.createStandardContextMenu(self) formattext_action = None if isinstance(self.hl, XmlHighlighter): formattext_action = QAction("Format XML", self, statusTip="", triggered=self.toprettyxml) else: formattext_action = QAction("Format as YAML", self, statusTip="", triggered=self.toprettyyaml) formattext_action.setShortcuts(QKeySequence("Ctrl+Shift+F")) menu.addAction(formattext_action) # if not self.textCursor().selectedText(): # self.setTextCursor(self.cursorForPosition(pos)) submenu = self._create_context_menu_for_tag() if submenu is not None: menu.addMenu(submenu) argmenu = self._create_context_substitution_menu() if argmenu is not None: menu.addMenu(argmenu) menu.exec_(self.mapToGlobal(pos))
def show_custom_context_menu(self, pos): menu = QTextEdit.createStandardContextMenu(self) # if not self.textCursor().selectedText(): # self.setTextCursor(self.cursorForPosition(pos)) submenu = self._create_context_menu_for_tag() if submenu is not None: menu.addMenu(submenu) argmenu = self._create_context_substitution_menu() if argmenu is not None: menu.addMenu(argmenu) menu.exec_(self.mapToGlobal(pos))
def show_custom_context_menu(self, pos): menu = QTextEdit.createStandardContextMenu(self) # if not self.textCursor().selectedText(): # self.setTextCursor(self.cursorForPosition(pos)) submenu = self._create_context_menu_for_tag() if submenu is not None: menu.addMenu(submenu) argmenu = self._create_context_substitution_menu() if argmenu is not None: menu.addMenu(argmenu) menu.exec_(self.mapToGlobal(pos))