Skip to content

Commit

Permalink
chore(examples): update custom_titlbar example with app-region: drag (
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir authored May 23, 2024
1 parent f089964 commit 50ec050
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/custom_titlebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ fn main() -> wry::Result<()> {
box-sizing: border-box;
}
*[data-wry-darg-region] {
app-region: drag; /* Supported on Windows only, on WebView2 123+ and makes dragging with touch work */
}
main {
display: grid;
place-items: center;
Expand Down Expand Up @@ -168,7 +172,7 @@ fn main() -> wry::Result<()> {
<body>
<div class="titlebar">
<div class="drag-region">Custom Titlebar</div>
<div data-wry-darg-region>Custom Titlebar</div>
<div>
<div class="titlebar-button" onclick="window.ipc.postMessage('minimize')">
<img src="https://api.iconify.design/codicon:chrome-minimize.svg" />
Expand All @@ -187,7 +191,7 @@ fn main() -> wry::Result<()> {
<script>
document.addEventListener('mousemove', (e) => window.ipc.postMessage(`mousemove:${e.clientX},${e.clientY}`))
document.addEventListener('mousedown', (e) => {
if (e.target.classList.contains('drag-region') && e.buttons === 1) {
if (e.target.hasAttribute('data-wry-darg-region') && e.button === 0) {
e.detail === 2
? window.ipc.postMessage('maximize')
: window.ipc.postMessage('drag_window');
Expand All @@ -196,7 +200,7 @@ fn main() -> wry::Result<()> {
}
})
document.addEventListener('touchstart', (e) => {
if (e.target.classList.contains('drag-region')) {
if (e.target.hasAttribute('data-wry-darg-region')) {
window.ipc.postMessage('drag_window');
}
})
Expand Down

0 comments on commit 50ec050

Please sign in to comment.