Giter VIP home page Giter VIP logo

Comments (15)

jvdwetering avatar jvdwetering commented on August 25, 2024 1

Yeah for pip I have to make a separate release for which I want to bunch up a bit more stuff than just pushing a single commit at once.

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

A workaround that seems to work for me is to replace ctrlKey for altKey in the file zx_editor_widget.js

from pyzx.

jvdwetering avatar jvdwetering commented on August 25, 2024

I don't have a mac so I can't test for myself, can you see if the following fix works.
Lines 81-85 of zx_editor_widget.js are
.on("keydown.brush", function() {shiftKey = d3.event.shiftKey || d3.event.metaKey; ctrlKey = d3.event.ctrlKey;}) .on("keyup.brush", function() {shiftKey = d3.event.shiftKey || d3.event.metaKey; ctrlKey = d3.event.ctrlKey;})

Change this to:
.on("keydown.brush", function() {shiftKey = d3.event.shiftKey; ctrlKey = d3.event.ctrlKey || d3.event.metaKey;}) .on("keyup.brush", function() {shiftKey = d3.event.shiftKey; ctrlKey = d3.event.ctrlKey || d3.event.metaKey;})
(i.e. make metaKey a synonym for ctrl)
Then you should be able to use Command+Click on Mac to do the thing that requires ctrl+click on Windows.

from pyzx.

jvdwetering avatar jvdwetering commented on August 25, 2024

Hmm, although looking at other parts of the code in that file, it seems that I would have to restructure it to actually use those local variables shiftKey and ctrlKey, instead of relying on the d3.event.ctrlKey thing.

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

I don't have a mac so I can't test for myself, can you see if the following fix works.
Lines 81-85 of zx_editor_widget.js are
.on("keydown.brush", function() {shiftKey = d3.event.shiftKey || d3.event.metaKey; ctrlKey = d3.event.ctrlKey;}) .on("keyup.brush", function() {shiftKey = d3.event.shiftKey || d3.event.metaKey; ctrlKey = d3.event.ctrlKey;})

Change this to:
.on("keydown.brush", function() {shiftKey = d3.event.shiftKey; ctrlKey = d3.event.ctrlKey || d3.event.metaKey;}) .on("keyup.brush", function() {shiftKey = d3.event.shiftKey; ctrlKey = d3.event.ctrlKey || d3.event.metaKey;})
(i.e. make metaKey a synonym for ctrl)
Then you should be able to use Command+Click on Mac to do the thing that requires ctrl+click on Windows.

Unfortunately, this didn't seem to work for me, but I did try again what I suggested but this time replacing all ctrlKey with metaKey and it worked now with Command+click, as one would expect. But maybe this is not ideal in other parts of the code.

from pyzx.

jvdwetering avatar jvdwetering commented on August 25, 2024

Great! I can work with that. I can just make all ctrlKey a ctrlKey || metaKey (and update the docs).

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

Great thanks! A tangentially related observation: In the iPad (which I sometimes use to code quick stuff) is kind of hard to press a key and click at the same time. I checked and the widget ctrl+click works with a trackpad, but not when you press ctrl and touch on the screen (which should in principle be equivalent to a ctrl+click in general). Not sure if there is a quick solution for this.

from pyzx.

jvdwetering avatar jvdwetering commented on August 25, 2024

So it looks like javascript makes a difference between 'click' events and 'touch' events that might be causing this behaviour.
https://stackoverflow.com/questions/11397028/document-click-function-for-touch-device
But it also says that most browsers should fire a click event when you touch the screen.

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

I see. I am using an app called Juno Connect to run a notebook on a remote server, so it is not precisely a browser.
Perhaps if I try to forward it to the browser it might work. It would be nice to get the app compatibility though! but I understand maybe not a priority.

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

I also tried to run pyzx in the Juno app (different from Juno Connect) which allows a local version of a code to run, but I couldn't get the package to import

IMG_02CB38DC0F6F-1
IMG_1423

from pyzx.

jvdwetering avatar jvdwetering commented on August 25, 2024

Hmm, the error originates from a call in typing.py, which makes me think that Juno is perhaps expecting an older version of python or doesn't have fully compatibility with mypy?

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

I just installed mypy 0.782, which runs on Juno (I can import the package).
Juno runs on Python 3.6.6 so maybe there is some incompatibility?

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

Although Juno only works with pure python packages though (at least this is what they say ), could this be an issue?

from pyzx.

jvdwetering avatar jvdwetering commented on August 25, 2024

I've just pushed a commit that should allow you to use command-click in the editor. Can you test whether it works for you?

from pyzx.

aggrushin avatar aggrushin commented on August 25, 2024

Indeed it works. The file wasn't updated downloading from the pip (not sure how pip updates upon new commits), but when I added the file it worked :) Thanks!

from pyzx.

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.