5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 03:52:41 +08:00

[windows] Allow single-clicks on wails-draggable items (#2482)

* [runtime] Make it possible to restore old drag behaviour on windows with window.wails.flags.deferDragToMouseMove

* [runtime] Use deferDragToMouseMove as new default

This enhanced version should work well in all cases for Windows:
- No lag/delayed start of dragging
- Double-Clicks and Single-Click events still work in JavaScript on elements

* [docs] Add changelog
This commit is contained in:
stffabi 2023-03-20 08:45:21 +01:00 committed by GitHub
parent 77f053068c
commit 47af68a8cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 12 deletions

View File

@ -66,7 +66,7 @@ window.wails = {
defaultCursor: null, defaultCursor: null,
borderThickness: 6, borderThickness: 6,
shouldDrag: false, shouldDrag: false,
deferDragToMouseMove: false, deferDragToMouseMove: true,
cssDragProperty: "--wails-draggable", cssDragProperty: "--wails-draggable",
cssDragValue: "drag", cssDragValue: "drag",
} }
@ -152,10 +152,9 @@ function setResize(cursor) {
window.addEventListener('mousemove', function (e) { window.addEventListener('mousemove', function (e) {
if (window.wails.flags.shouldDrag) { if (window.wails.flags.shouldDrag) {
let mousePressed = e.buttons !== undefined ? e.buttons : e.which;
if(mousePressed <= 0) {
window.wails.flags.shouldDrag = false; window.wails.flags.shouldDrag = false;
} else { let mousePressed = e.buttons !== undefined ? e.buttons : e.which;
if (mousePressed > 0) {
window.WailsInvoke("drag"); window.WailsInvoke("drag");
return; return;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Support single clicks on items with `--wails-draggable: drag` again on Windows. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2482)
### Fixed ### Fixed
- Fixed panic when using `wails dev` and the AssetServer tried to log to the logger. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2481) - Fixed panic when using `wails dev` and the AssetServer tried to log to the logger. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2481)
- Fixed compatibility with WebView2 Runtime > `110.0.1587.69` which showed a `connection refused` html page before doing a reload of the frontend. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2496) - Fixed compatibility with WebView2 Runtime > `110.0.1587.69` which showed a `connection refused` html page before doing a reload of the frontend. Fixed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2496)