mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
fix cutting and copying between fields
the shortcut keys are handled by webengine on platforms other than osx, so rather than messing with an event filter we catch the cut and copy events in js and send a signal back
This commit is contained in:
parent
be14703e7f
commit
a7ed7fa4e3
2 changed files with 14 additions and 2 deletions
|
@ -646,6 +646,9 @@ to a cloze type first, via Edit>Change Note Type."""))
|
|||
def onPaste(self):
|
||||
self.web.onPaste()
|
||||
|
||||
def onCutOrCopy(self):
|
||||
self.web.flagAnkiText()
|
||||
|
||||
# Advanced menu
|
||||
######################################################################
|
||||
|
||||
|
@ -693,6 +696,7 @@ to a cloze type first, via Edit>Change Note Type."""))
|
|||
more=onAdvanced,
|
||||
dupes=showDupes,
|
||||
paste=onPaste,
|
||||
cutOrCopy=onCutOrCopy,
|
||||
)
|
||||
|
||||
# Pasting, drag & drop, and keyboard layouts
|
||||
|
@ -715,11 +719,9 @@ class EditorWebView(AnkiWebView):
|
|||
self._flagAnkiText()
|
||||
|
||||
def onCut(self):
|
||||
self._markInternal = True
|
||||
self.triggerPageAction(QWebEnginePage.Cut)
|
||||
|
||||
def onCopy(self):
|
||||
self._markInternal = True
|
||||
self.triggerPageAction(QWebEnginePage.Copy)
|
||||
|
||||
def onPaste(self):
|
||||
|
@ -819,6 +821,10 @@ class EditorWebView(AnkiWebView):
|
|||
# add to media and return resulting html link
|
||||
return self.editor._addMedia(newpath)
|
||||
|
||||
def flagAnkiText(self):
|
||||
# be ready to adjust when clipboard event fires
|
||||
self._markInternal = True
|
||||
|
||||
def _flagAnkiText(self):
|
||||
# add a comment in the clipboard html so we can tell text is copied
|
||||
# from us and doesn't need to be stripped
|
||||
|
|
|
@ -258,6 +258,11 @@ function wrap(front, back) {
|
|||
}
|
||||
}
|
||||
|
||||
function onCutOrCopy() {
|
||||
pycmd("cutOrCopy");
|
||||
return true;
|
||||
}
|
||||
|
||||
function setFields(fields, prewrap) {
|
||||
var txt = "";
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
|
@ -270,6 +275,7 @@ function setFields(fields, prewrap) {
|
|||
txt += "<div id=f{0} onkeydown='onKey();' oninput='checkForEmptyField()' onmouseup='onKey();'".format(i);
|
||||
txt += " onfocus='onFocus(this);' onblur='onBlur();' class=field ";
|
||||
txt += "ondragover='onDragOver(this);' onpaste='onPaste(this);' ";
|
||||
txt += "oncopy='onCutOrCopy(this);' oncut='onCutOrCopy(this);' ";
|
||||
txt += "contentEditable=true class=field>{0}</div>".format(f);
|
||||
txt += "</td></tr>";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue