aframevr / aframe-inspector

:mag: Visual inspector tool for A-Frame. Hit *<ctrl> + <alt> + i* on any A-Frame scene.
https://aframe.io/aframe-inspector/examples/
MIT License
654 stars 201 forks source link

Do not fire hotkey commands based off of active element, but prevent #410

Closed jsantell closed 7 years ago

jsantell commented 7 years ago

input elements from propagating events to document if they should not be acted on. Fixes #406

jsantell commented 7 years ago

Using the method described in #406 -- any issues you think with this approach? Or any input field areas that aren't accounted for? Works best alongside #407 so that hotkeys are also usable when selecting the first entity

fernandojsg commented 7 years ago

What about, instead of including stopPropagating on every possible input control, modify the code for shouldCaptureKeyEvent for the inspector? Something like:

function shouldCaptureKeyEvent(event) {
  if (event.metaKey) { return false; }
  return document.activeElement === document.body &&
    (event.target.tagName !== 'INPUT' ||
    event.target.tagName !== 'TEXTAREA');
}
jsantell commented 7 years ago

@fernandojsg That would work as well! My only concern would be interactions like arrow keys moving the camera around when the Entities panel has focus (would scroll the panel instead), but seems like a separate issue of handling focus (and not sure which behaviour is even preferred!) -- all in all, I think the solution of checking for origin of the event and canceling on input elements would be the smallest change for now!

jsantell commented 7 years ago

That being said, I believe document.activeElement === document.body is the part that is currently preventing shortcuts from occuring when the entities panel has focus, as the SceneGraph's .outliner div steals focus

jsantell commented 7 years ago

Pushed a change based on feedback

fernandojsg commented 7 years ago

Cool! thank you