这是indexloc提供的服务,不要输入任何密码
Skip to content

Feature Request] Option to disable zooming (Ctrl + Scroll / Ctrl + +/-) in WebView #4434

@Josefh90

Description

@Josefh90

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions