Giter VIP home page Giter VIP logo

Comments (5)

abdnh avatar abdnh commented on June 15, 2024

After some experimentation, I've found that the freeze can be eliminated by explicitly handling dragEnterEvent in EditorWebView, like this:

def dragEnterEvent(self, evt):
  evt.accept()

But this prevents the fields from receiving the dragover event, as a result, the onDragOver function in editor.ts is never called.
The issue does not seem to be caused by anything in editor.ts. merely handling dragEnterEvent fixes it, but introduces another problem.

from anki.

dae avatar dae commented on June 15, 2024

Thanks for digging into it, I'll have another play with it when I have a chance

from anki.

abdnh avatar abdnh commented on June 15, 2024

It seems that the dragover JavaScript event is triggered in the default dragEnterEvent handler of QWebEngineView.
The following causes the dragover event to be fired as usual but reintroduces the freeze:

def dragEnterEvent(self, evt):
    super().dragEnterEvent(evt)

Doing something similar in dropEvent eliminates the freeze:

def dropEvent(self, evt):
    super().dropEvent(evt)

But this brings with it the default handling of drop events in addtion to Anki's handling (e.g. dropped images will be opened and copied to fields). Also, calling evt.setDropAction(Qt.IgnoreAction) doesn't seem to help.

The whole thing can be reproduced outside Anki (as in this example).
I think this is ultimately a QT bug. I guess it would be more reasonable that JavaScript events fire regardless of custom QT event handlers.

from anki.

abdnh avatar abdnh commented on June 15, 2024

I've found a workaround:
abdnh@c46aaa0

Please let me know if it's any good.

from anki.

dae avatar dae commented on June 15, 2024

Thanks ANH - I didn't notice any problems, and it seems to work well here. I'm sure this will make a bunch of users happy!

Merged in #738

from anki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.