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

Keydown event at bubbling phase #635

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/application/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ export class Application<T extends Widget = Widget> {
// Mark the application as started;
this._started = true;

this._bubblingKeydown = options.bubblingKeydown || false;
brichet marked this conversation as resolved.
Show resolved Hide resolved

// Parse the host ID for attaching the shell.
const hostID = options.hostID || '';

Expand Down Expand Up @@ -606,8 +608,11 @@ export class Application<T extends Widget = Widget> {
* A subclass may reimplement this method as needed.
*/
protected addEventListeners(): void {
if (this._bubblingKeydown) {
console.log('The keydown events are handled during bubbling phase');
}
document.addEventListener('contextmenu', this);
document.addEventListener('keydown', this, true);
document.addEventListener('keydown', this, !this._bubblingKeydown);
window.addEventListener('resize', this);
}

Expand Down Expand Up @@ -663,6 +668,7 @@ export class Application<T extends Widget = Widget> {
private _plugins = new Map<string, Private.IPluginData>();
private _services = new Map<Token<any>, string>();
private _started = false;
private _bubblingKeydown = false;
}

/**
Expand Down Expand Up @@ -715,6 +721,8 @@ export namespace Application {
* This will override `startPlugins` and any `autoStart` plugins.
*/
ignorePlugins?: string[];

brichet marked this conversation as resolved.
Show resolved Hide resolved
bubblingKeydown?: boolean;
brichet marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading