Giter VIP home page Giter VIP logo

Comments (7)

emilk avatar emilk commented on June 30, 2024

A quick-fix is to ignore certain events (like "space") when the egui viewport doesn't have focus (ctx.input(|i| i.focused)), but that's assuming focused is correctly set (which I'm not sure it is).

from rerun.

emilk avatar emilk commented on June 30, 2024

From slack discussion: we should consider moving the keydown event handler from document to canvas here:

https://github.com/emilk/egui/blob/7bd0a4f7965ebade3c03403d0014bd7e60e67132/crates/eframe/src/web/events.rs#L70-L73

If we do we need to make sure that the canvas gets automatic focus (e.g. on egui.rs and rerui.io/viewer).

In general, any events that can be moved from document to canvas without loss of functionality should be moved in order to better support multiple eframe viewports in the same web view.

Some events, like keyup, should probably stay on document so that we don't miss a key release on e.g. (alt-)tab or similar.

For the events that are installed on document:

  • check for focus in any document/window events before doing anything, especially preventDefault/stopPropagation

from rerun.

jprochazk avatar jprochazk commented on June 30, 2024

In order for the canvas element to be able to accept focus, it also needs to have a tabIndex="0" attribute set. The 0 ensures that the canvas follows the focus order defined by the order in the document source.

from rerun.

emilk avatar emilk commented on June 30, 2024

We decided to do a quick-fix for this for now:

Ignore some key presses (space, arrow keys) in Rerun on web if mouse cursor isn't inside the viewer canvas. @jleibs is taking the lead on this.

from rerun.

jleibs avatar jleibs commented on June 30, 2024

Playing around with this the proposed solution still feels quite awkward.

In particular, it becomes evident that keyboard shortcuts are broken in other ways. Events sent while the viewer is in focus still also get processed by the notebook. For example hitting "space" triggers a page-down.

from rerun.

jleibs avatar jleibs commented on June 30, 2024

I realized this is in fact a regression, which is why nobody has complained. This is one of the things we were getting "for free" from the fact that the viewer was previously embedded in an iframe.

from rerun.

jleibs avatar jleibs commented on June 30, 2024

Additional notes:

There is a second regression which is that jupyter notebook (classic) sometimes responds to Rerun events. In particular, the "a" key when trying to navigate.

I believe this can be traced back to jupyter's keyboard manage itself being somewhat poorly behaved:
https://github.com/jupyter/nbclassic/blob/main/nbclassic/static/notebook/js/keyboardmanager.js#L175-L183

It might be possible for us to detect when we have focus and manually disable the jupyter keybooard manager: https://github.com/jupyter/notebook/blob/ca50f1af5afb525fd95b98b2e61e69db28094467/notebook/static/notebook/js/keyboardmanager.js#L234

This is not an issue in jupyterlab, which appears to follow better practices for event handling.

from rerun.

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.