Skip to content

Commit

Permalink
feat: add Platform#setTabindex()
Browse files Browse the repository at this point in the history
  • Loading branch information
yu-ogi committed Oct 13, 2023
1 parent 5c31da8 commit aac63d2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## unreleased changes
* `Platform#setTabindex()` を追加
* `InputHandler``view` の Element に `tabindex: 0` をデフォルトで付与するように
* これはバージョン 2.4.3 以前の挙動と同様となります。

## 2.8.0
* @akashic/pdi-types@1.12.0 に追従
* `PointerEvent` サポート環境において `PointMoveEvent#button`, `PointUpEvent#button` に対応
Expand Down
4 changes: 4 additions & 0 deletions src/ContainerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export class ContainerController {
}
}

setTabindex(index: number | undefined): void {
this.inputHandlerLayer.setViewTabindex(index);
}

private _loadView(): void {
const { primarySurfaceWidth: width, primarySurfaceHeight: height } = this._rendererReq;
// DocumentFragmentはinsertした時点で開放されているため毎回作る
Expand Down
6 changes: 6 additions & 0 deletions src/InputHandlerLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ export class InputHandlerLayer {
view.style.height = size.height + "px";
}

setViewTabindex(tabindex: number | undefined): void {
const view = this.view;
view.setAttribute("tabindex", tabindex == null ? "" : tabindex.toString());
}

private _createInputView(width: number, height: number): HTMLDivElement {
const view = document.createElement("div");
view.setAttribute("style", "display:inline-block; outline:none;");
view.style.width = width + "px";
view.style.height = height + "px";
view.setAttribute("tabindex", "0");
return view;
}
}
4 changes: 4 additions & 0 deletions src/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export class Platform implements pdi.Platform {
return this._audioManager.getMasterVolume();
}

setTabindex(tabindex: number | undefined): void {
this.containerController.setTabindex(tabindex);
}

destroy(): void {
this.setRendererRequirement(undefined);
this.setMasterVolume(0);
Expand Down

0 comments on commit aac63d2

Please sign in to comment.