-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Is your feature request related to a problem? Please describe.
In my Wails v2 application, I want to prevent users from zooming in or out using Ctrl + Scroll, Ctrl + +/-, or Cmd + +/-. Currently, the default behavior of the WebView allows zooming, which can break layout, fonts, and UX.
Describe the solution you'd like
It would be great to have a native Wails config option such as:
ZoomEnabled: false
inside the options.App{} struct passed to wails.Run, which disables zooming behavior entirely at the WebView level, ideally in a cross-platform manner (Windows/WebView2, macOS/WebKit, Linux/WebKitGTK).
Describe alternatives you've considered
useEffect(() => {
const preventZoom = (e: WheelEvent | KeyboardEvent) => {
if ((e instanceof WheelEvent && e.ctrlKey) ||
(e instanceof KeyboardEvent && (e.ctrlKey || e.metaKey) &&
(e.key === '+' || e.key === '-' || e.key === '='))) {
e.preventDefault();
}
};
window.addEventListener('wheel', preventZoom, { passive: false });
window.addEventListener('keydown', preventZoom, { passive: false });
return () => {
window.removeEventListener('wheel', preventZoom);
window.removeEventListener('keydown', preventZoom);
};
}, []);
This works, but a built-in Go-side configuration would be much cleaner and more intuitive.
Additional context
A config option would help keep frontend code simpler and avoid the need to duplicate this workaround in every app. Especially in security-sensitive tools, fixed zoom is crucial for layout control.