Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

keyboard handler added #350

Merged
merged 5 commits into from
Dec 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"colors": "^1.1.0",
"del": "^1.2.1",
"express": "^4.10.4",
"gulp": "^3.9.0",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^2.3.1",
"gulp-batch": "^1.0.5",
"gulp-changed": "^1.3.0",
Expand Down
16 changes: 15 additions & 1 deletion src/components/Callout/Callout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace fabric {

private _setOpener() {
this._addTarget.addEventListener("click", this._clickHandler.bind(this), true);
this._addTarget.addEventListener("keyup", this._keyupHandler.bind(this), true);
}

private _openContextMenu() {
Expand Down Expand Up @@ -63,13 +64,26 @@ namespace fabric {
}

private _closeHandler(e) {
this._contextualHost.disposeModal();
if (this._contextualHost != null) {
this._contextualHost.disposeModal();
}
this._closeButton.removeEventListener("click", this._closeHandler.bind(this), false);
this._addTarget.removeEventListener("click", this._clickHandler.bind(this), true);
this._addTarget.removeEventListener("keyup", this._keyupHandler.bind(this), true);
}

private _clickHandler(e) {
this._openContextMenu();
}

private _keyupHandler(event: KeyboardEvent): void {
if (event.keyCode === 32) {
event.stopPropagation();
event.preventDefault();
this._openContextMenu();
} else {
this._closeHandler(event);
}
}
}
}