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:
parent
77f053068c
commit
47af68a8cb
@ -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",
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ window.addEventListener('mousedown', (e) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (window.wails.flags.deferDragToMouseMove) {
|
if (window.wails.flags.deferDragToMouseMove) {
|
||||||
window.wails.flags.shouldDrag = true;
|
window.wails.flags.shouldDrag = true;
|
||||||
} else {
|
} else {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
window.WailsInvoke("drag");
|
window.WailsInvoke("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) {
|
||||||
|
window.wails.flags.shouldDrag = false;
|
||||||
let mousePressed = e.buttons !== undefined ? e.buttons : e.which;
|
let mousePressed = e.buttons !== undefined ? e.buttons : e.which;
|
||||||
if(mousePressed <= 0) {
|
if (mousePressed > 0) {
|
||||||
window.wails.flags.shouldDrag = false;
|
|
||||||
} else {
|
|
||||||
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
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user