I'm trying to add a functionality to a text box where a user can highlight a word, right click and be able to choose whether to define or get synonyms for the highlighted word. I coded a context menu but it only appears when I click outside of the textbox. Is there anyway I can add functions to the default context menu that includes Copy, Paste, etc.? Here is my code for the context menu.
self.setContextMenuPolicy(Qt.ActionsContextMenu)
defineAction = QtWidgets.QAction("Define", self)
defineAction.triggered.connect(lambda: self.define(event))
self.addAction(defineAction)
synonymAction = QtWidgets.QAction("Find Synonyms", self)
synonymAction.triggered.connect(lambda: self.synonym(event))
self.addAction(synonymAction)