Skip to content
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

captureKeys flag #138

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

captureKeys flag #138

wants to merge 3 commits into from

Conversation

georgealways
Copy link
Owner

@georgealways georgealways commented May 25, 2024

Adds a flag captureKeys to GUI's constructor. If this is false, GUI will not call stopPropagation() on key events that originate from within the GUI. The user must then manage event propagation manually using the following or similar.

const gui = new GUI( { captureKeys: false } );
window.addEventListener( 'keydown', e => { 
  if ( gui.contains( document.activeElement ) ) return;
  if ( e.code === 'Space' ) jump();
}

Writing tests for this was tricky. The browser shim needed to be expanded to simulate event propagation.

Open question: Right now, folders titles are treated differently than Controllers. They never capture key events (mostly because of #69). I'm wondering if we should keep this special treatment, or if the captureKeys flag would apply to both Controllers and folder titles in the same way.

Note to self: the base for this branch was title-as-button. Merge that first.

@georgealways georgealways added this to the 0.19.2-dev milestone May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lil-gui retaining focus on Windows? Folder close or open eats keystrokes
1 participant