Comments (15)
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.
A workaround that seems to work for me is to replace ctrlKey for altKey in the file zx_editor_widget.js
from pyzx.
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.
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.
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.
Great! I can work with that. I can just make all ctrlKey a ctrlKey || metaKey (and update the docs).
from pyzx.
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.
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.
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.
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
from pyzx.
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.
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.
Although Juno only works with pure python packages though (at least this is what they say ), could this be an issue?
from pyzx.
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.
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)
- support `reset` and `measure` in qasmparser HOT 1
- a round-trip through `graph_to_json` and `json_to_graph` renumbers the vertices HOT 4
- After applying simplifications the unitary matrices change. HOT 10
- Error in basic_optimization HOT 4
- update readthedocs.io to v0.8.0 HOT 1
- Error in full_optimize HOT 2
- Is spider rule likely buggy? HOT 12
- Hadamard cancellation rule HOT 4
- `Graph.to_json` followed by `pyzx.json_to_graph` produces an error HOT 2
- use Python's native `@deprecated` decorator HOT 1
- quimb test is broken
- `extract_circuit` does not turn grounds into measurements and classically-conditioned gates HOT 3
- pyzx unable to optimize when circuit contains rx or sx gate HOT 3
- support custom gates with phases HOT 1
- rename `master` branch to `main`
- `pyzx.draw()` does not work in some matplotlib environments HOT 2
- Qiskit 1.0 OpenQASM 3 output breaks `qasmparser` because of spaces between phases
- `U3Gate` is deprecated in Qiskit 1.0, replaced with `UGate`, pyzx needs to handle the new gate
- `pyzx.draw()` is incompatible with dark background HOT 2
- Clifford simp adds a phase of n*pi/2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyzx.