Skip to content

Commit

Permalink
Allows a (experimental) parameter when starting application to handle…
Browse files Browse the repository at this point in the history
… the keydown event at bubbling phase
  • Loading branch information
brichet committed Sep 21, 2023
1 parent 968064a commit 50529d2
Showing 1 changed file with 9 additions and 1 deletion.
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;

// 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[];

bubblingKeydown?: boolean;
}
}

Expand Down

0 comments on commit 50529d2

Please sign in to comment.