diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 890c4dc88b0..50c4fdfe7e7 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -379,11 +379,15 @@ def onSelectAll(self) -> None: def contextMenuEvent(self, evt: QContextMenuEvent) -> None: m = QMenu(self) - a = m.addAction(tr.actions_copy()) - qconnect(a.triggered, self.onCopy) + self._maybe_add_copy_action(m) gui_hooks.webview_will_show_context_menu(self, m) m.popup(QCursor.pos()) + def _maybe_add_copy_action(self, menu: QMenu) -> None: + if self.hasSelection(): + a = menu.addAction(tr.actions_copy()) + qconnect(a.triggered, self.onCopy) + def dropEvent(self, evt: QDropEvent) -> None: if self.allow_drops: super().dropEvent(evt)