Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Clean up keyboard handling #1060

Closed
natduca opened this issue Jun 30, 2015 · 1 comment
Closed

Clean up keyboard handling #1060

natduca opened this issue Jun 30, 2015 · 1 comment
Assignees

Comments

@natduca
Copy link
Contributor

natduca commented Jun 30, 2015

The keyboard handling code in trace viewer is a nightmare: we have a few global document key listeners, and then a pile of hacky code to fix complications arising from this basic mistake.

We should fix it.

@natduca natduca self-assigned this Jun 30, 2015
@natduca
Copy link
Contributor Author

natduca commented Jun 30, 2015

natduca added a commit that referenced this issue Jul 1, 2015
The old key handling architecture had a ton of nasty hacks for whether the
timeline is listening to keys (listensToKeys). This mess stems from a few things:
- Some of our components have local hotkeys that need to get called even when
  they dont have keyboard focus. For instance, the wasd keys should work
  in the track view even when some other panel has focus.
- Sometimes the toplevel timeline view doesn't have keyboard focus. In the
  single-timeline-view-fills-the-screen use cases, we still want the timeline
  view to get foucs.

The old architecture addresses this by having tons of global key event
listeners and then piles of hacks to turn off the global behavior when we think
that the timeline-view is not focused.

The new architecture is more modular. Individual components that want to have
hotkeys create and attach a <tr-ui-b-hotkey-controller> element. They then add their
local hotkeys to that object. Hotkeys are strongly typed, so that we can generate help
text automatically down the road.

Internally, the hotkey controllers talk to each other to find the topmost controller. That
topmost controller creates the actual keypress/down listeners, and then does all event dispatch for
all controllers in that subtree.

Notably, the mouse mode selector does not use the new hotkey controller. This is because the
mode selector is quirky: instead of plain hotkeys, its state changes in direct response to modifier
keydown/key up events. Rather than complicating the hotkey controllers design to accommodate the
mouse mode selectors stuff, it directly listens to the modifier keys: to do this and avoid leaking
the selector object due to document-owning-a-backpointer-to-an-element, we rewrite the component
to be polymer, which allows us to register for document listeners in the attached/detached lifecycle callbacks.

BUG=#1060

Review URL: https://codereview.appspot.com/239280043
@natduca natduca closed this as completed Jul 1, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant