--- a/src/eric7/QScintilla/Editor.py Fri Dec 23 10:58:36 2022 +0100 +++ b/src/eric7/QScintilla/Editor.py Fri Dec 23 11:35:54 2022 +0100 @@ -553,6 +553,8 @@ self.__initContextMenu() self.__initContextMenuMargins() + self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) + self.customContextMenuRequested.connect(self.__showContextMenu) self.__checkEol() if editor is None: @@ -982,7 +984,7 @@ self.__contextSaveCopy, ) - self.menu.aboutToShow.connect(self.__showContextMenu) + self.menu.aboutToShow.connect(self.__aboutToShowContextMenu) self.spellingMenu = QMenu() self.__menus["Spelling"] = self.spellingMenu @@ -5593,35 +5595,36 @@ return margin return -1 - def contextMenuEvent(self, evt): - """ - Protected method implementing the context menu event. - - @param evt the context menu event (QContextMenuEvent) - """ - evt.accept() - if self.__marginNumber(evt.x()) == -1: - self.spellingMenuPos = self.positionFromPoint(evt.pos()) + @pyqtSlot(QPoint) + def __showContextMenu(self, pos): + """ + Private slot to show a context menu. + + @param pos position for the context menu + @type QPoint + """ + if self.__marginNumber(pos.x()) == -1: + self.spellingMenuPos = self.positionFromPoint(pos) if ( self.spellingMenuPos >= 0 and self.spell is not None and self.hasIndicator(self.spellingIndicator, self.spellingMenuPos) ): - self.spellingMenu.popup(evt.globalPos()) + self.spellingMenu.popup(self.mapToGlobal(pos)) else: - self.menu.popup(evt.globalPos()) - else: - self.line = self.lineAt(evt.pos()) - if self.__marginNumber(evt.x()) in [self.__bmMargin, self.__linenoMargin]: - self.bmMarginMenu.popup(evt.globalPos()) - elif self.__marginNumber(evt.x()) == self.__bpMargin: - self.bpMarginMenu.popup(evt.globalPos()) - elif self.__marginNumber(evt.x()) == self.__indicMargin: - self.indicMarginMenu.popup(evt.globalPos()) - elif self.__marginNumber(evt.x()) == self.__foldMargin: - self.foldMarginMenu.popup(evt.globalPos()) - - def __showContextMenu(self): + self.menu.popup(self.mapToGlobal(pos)) + else: + self.line = self.lineAt(pos) + if self.__marginNumber(pos.x()) in [self.__bmMargin, self.__linenoMargin]: + self.bmMarginMenu.popup(self.mapToGlobal(pos)) + elif self.__marginNumber(pos.x()) == self.__bpMargin: + self.bpMarginMenu.popup(self.mapToGlobal(pos)) + elif self.__marginNumber(pos.x()) == self.__indicMargin: + self.indicMarginMenu.popup(self.mapToGlobal(pos)) + elif self.__marginNumber(pos.x()) == self.__foldMargin: + self.foldMarginMenu.popup(self.mapToGlobal(pos)) + + def __aboutToShowContextMenu(self): """ Private slot handling the aboutToShow signal of the context menu. """