mirror of
https://github.com/ankitects/anki.git
synced 2025-11-12 23:57:13 -05:00
fix drag & drop copying instead of cutting
This commit is contained in:
parent
bd2c109d15
commit
63990af4b2
1 changed files with 9 additions and 6 deletions
|
|
@ -45,9 +45,11 @@ body { margin: 5px; }
|
||||||
</style><script>
|
</style><script>
|
||||||
%s
|
%s
|
||||||
|
|
||||||
|
var currentField = null;
|
||||||
|
var changeTimer = null;
|
||||||
var insertHTMLOK = %s;
|
var insertHTMLOK = %s;
|
||||||
var savedSel = null;
|
var savedSel = null;
|
||||||
|
var dropTarget = null;
|
||||||
|
|
||||||
String.prototype.format = function() {
|
String.prototype.format = function() {
|
||||||
var args = arguments;
|
var args = arguments;
|
||||||
|
|
@ -55,9 +57,6 @@ String.prototype.format = function() {
|
||||||
return args[m.match(/\d+/)]; });
|
return args[m.match(/\d+/)]; });
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentField = null;
|
|
||||||
var changeTimer = null;
|
|
||||||
|
|
||||||
function onKey() {
|
function onKey() {
|
||||||
// esc clears focus, allowing dialog to close
|
// esc clears focus, allowing dialog to close
|
||||||
if (window.event.which == 27) {
|
if (window.event.which == 27) {
|
||||||
|
|
@ -133,7 +132,9 @@ function focusField(n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDragOver(elem) {
|
function onDragOver(elem) {
|
||||||
elem.focus();
|
// if we focus the target element immediately, the drag&drop turns into a
|
||||||
|
// copy, so note it down for later instead
|
||||||
|
dropTarget = elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
function caretToEnd() {
|
function caretToEnd() {
|
||||||
|
|
@ -936,11 +937,13 @@ class EditorWebView(AnkiWebView):
|
||||||
return AnkiWebView.dropEvent(self, evt)
|
return AnkiWebView.dropEvent(self, evt)
|
||||||
else:
|
else:
|
||||||
mime = self._processMime(oldmime)
|
mime = self._processMime(oldmime)
|
||||||
# create a new event with the new mime data
|
# create a new event with the new mime data and run it
|
||||||
new = QDropEvent(evt.pos(), evt.possibleActions(), mime,
|
new = QDropEvent(evt.pos(), evt.possibleActions(), mime,
|
||||||
evt.mouseButtons(), evt.keyboardModifiers())
|
evt.mouseButtons(), evt.keyboardModifiers())
|
||||||
evt.accept()
|
evt.accept()
|
||||||
QWebView.dropEvent(self, new)
|
QWebView.dropEvent(self, new)
|
||||||
|
# tell the drop target to take focus so the drop contents are saved
|
||||||
|
self.eval("dropTarget.focus();")
|
||||||
|
|
||||||
def prepareClip(self, keep=False, mode=QClipboard.Clipboard):
|
def prepareClip(self, keep=False, mode=QClipboard.Clipboard):
|
||||||
clip = self.editor.mw.app.clipboard()
|
clip = self.editor.mw.app.clipboard()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue