5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-05 02:40:32 +08:00
wails/website/i18n/ja/docusaurus-plugin-content-docs/current/guides/mouse-buttons.mdx
github-actions[bot] 4cd873fecb
docs: sync documents (#2443)
Co-authored-by: misitebao <misitebao@users.noreply.github.com>
2023-03-11 17:57:56 +11:00

26 lines
1.0 KiB
Plaintext

# マウスボタン
Wailsランタイムでは、マウスクリックを途中で捕捉し、フレームレスウィンドウのサイズ変更が必要かどうかや、ウィンドウの移動が必要かどうかを判断しています。 `window.onclick`はマウスボタンを正しく報告しないため、どのようにマウスクリックが発生したことを検出しているのかを尋ねられました。 以下のコードは、マウスクリックを検出する方法を示しています:
```javascript
window.addEventListener("mousedown", handleMouseButtonDown);
function handleMouseButtonDown(event) {
if (event.button === 0) {
// left mouse button
} else if (event.button === 1) {
// middle mouse button
} else if (event.button === 2) {
// right mouse button
} else if (event.button === 3) {
// back mouse button
} else if (event.button === 4) {
// forward mouse button
} else {
// other mouse button
}
}
```
参考: https://developer.mozilla.org/ja/docs/Web/API/MouseEvent/button