Conversation
I have successfully implemented the disable pinch zoom functionality for the Wails WebView2 project. Here's what was implemented:
### Changes Made:
1. **Added PinchZoom Capability** (`pkg/edge/capabilities.go:144`)
- Added `PinchZoom = Capability("87.0.664.75")` to define the minimum WebView2 runtime version required
2. **Added Pinch Zoom Control Methods** (`pkg/edge/chromium.go:665-695`)
- `GetIsPinchZoomEnabled() (bool, error)` - Get current pinch zoom setting
- `PutIsPinchZoomEnabled(enabled bool) error` - Set pinch zoom setting
3. **Added Configuration Field** (`pkg/edge/chromium.go:79`)
- `PinchZoomEnabled *bool` - Optional field to configure pinch zoom during initialization
4. **Automatic Configuration Application** (`pkg/edge/chromium.go:390-396`)
- Added logic to automatically apply the pinch zoom setting when the WebView2 is initialized
5. **Created Usage Example** (`examples/disable_pinch_zoom.go`)
- Comprehensive example showing three ways to control pinch zoom
### Usage Options:
**Method 1: Configure during initialization (Recommended)**
```go
chromium := edge.NewChromium()
pinchZoomDisabled := false
chromium.PinchZoomEnabled = &pinchZoomDisabled
// Setting will be automatically applied when Embed() is called
```
**Method 2: Runtime control**
```go
err := chromium.PutIsPinchZoomEnabled(false)
```
**Method 3: Check current setting**
```go
enabled, err := chromium.GetIsPinchZoomEnabled()
```
### Features:
- **Capability Check**: Automatically checks if the WebView2 runtime supports pinch zoom control
- **Error Handling**: Proper error handling for unsupported versions
- **Automatic Application**: Setting is applied automatically during WebView2 initialization
- **Runtime Control**: Can be changed dynamically after initialization
- **Cross-compilation**: Successfully builds for Windows target
This implementation addresses the GitHub issue #2021 by providing a clean, idiomatic Go API to disable pinch zoom functionality in Wails applications using WebView2.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



wailsapp/wails#2021