-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eframe web: ignore keyboard events unless canvas has focus #4718
Conversation
87ec7c8
to
c6980af
Compare
c6980af
to
62c8995
Compare
This solves most of rerun-io/rerun#6638 In a notebook context, Rerun no longer gets events when typing in notebook cells. However, the outer notebook still also receives keyboard events, even if they are supposed to be handled by Rerun and it's in focus. |
Right click does not work in a notebook context (both classic and lab). For example, right click on a view in the blueprint panel should bring up its context menu, but instead it always opens the notebook's context menu |
@jprochazk please see if the latest commit (616fa2b) fixes it. Otherwise this might be another case of Jupyter Notebook Classic install event handlers on |
I can confirm it's fixed with that commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
### What * Closes #6638 * Uses emilk/egui#4718 Instructions: ``` pixi run -e examples py-build-notebook pixi run -e examples jupyter notebook examples/python/notebook/cube.ipynb ``` Run the first few 3 cells. ### Known issues: - Hitting 'a' when the viewer selected still bypasses Rerun and adds a new preceding cell in the notebook. This is because of how Jupyter Notebook Classic does things. ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6674?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6674?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/6674) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`. --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* Fixes rerun-io/rerun#6638 * Related? emilk#4563 This improves how an eframe canvas works inside of a larger web page, and how it works when there are multiple eframe apps in the same page. `eframe` will set `tabindex="0"` on the canvas automatically, making it focusable. It will also set `outline: none` on the CSS, so the focused canvas won't have an ugly outline. ## Breaking changes You may wanna add this to your `index.html` to give the canvas focus on startup: ```js document.getElementById("the_canvas_id").focus(); ``` ## Test setup ```sh ./scripts/build_demo_web.sh ./scripts/start_server.sh open http://localhost:8888/multiple_apps.html ``` Then open the "Input Event History" and "Text Edit" windows ## Tested * Chromium * [x] drag-and-drop of files * Test both when a `TextEdit` is focused and when it is not: * [x] `Event::Key` * [x] `Event::Text` * [x] copy-cut-paste * [x] Wheel scroll * [x] `Event::PointerGone` * [x] Mouse drag * [x] Mouse click * [x] Mouse right-click * [x] Defocus all eframe canvas, and then start typing text * [x] Firefox (all of the above) * [x] Desktop Safari (all of the above) * [x] Mobile Safari ## Future work (pre-existing issues) * emilk#4723 * emilk#4724 * emilk#4725 * emilk#4726
This improves how an eframe canvas works inside of a larger web page, and how it works when there are multiple eframe apps in the same page.
eframe
will settabindex="0"
on the canvas automatically, making it focusable.It will also set
outline: none
on the CSS, so the focused canvas won't have an ugly outline.Breaking changes
You may wanna add this to your
index.html
to give the canvas focus on startup:Test setup
Then open the "Input Event History" and "Text Edit" windows
Tested
TextEdit
is focused and when it is not:Event::Key
Event::Text
Event::PointerGone
Future work (pre-existing issues)
mousemove
andmouseup
unless mouse is over canvas #4723keys_down
in bad state #4724