wails/v3/pkg/application/window.go
Atterpac 10447e6fcd
[V3] Drag-n-Drop Zones and improvements (#4318)
* new events

* macOS dnd improvements

* wailsio adds for dropzone

* update example

* sorta working

the top 300px of the window are not dropabble for some reason i suspect it has to do with the drag enter/drag leave xy as the performOperation needed to use the ContentView for appropriate X/Y

* implement attribute detection for data-wails-dropzone

* docs

* pass x/y dnd linux

* cleanup exmample

* changelog

* pass all attributes to golang on dragdrop

* filetree example

* fix dnd build windows

* Fix windows dnd

* update docs

* remove debug log

* appease the security bot

* Fix changelog

* Fix changelog

* Revert "Fix event generation issues."

This reverts commit ae4ed4fe

* Fix events

* Fix merge conflicts. Fix events generation formatting

* Update docs

* Fix duplicate bundledassets import causing build failures

Remove duplicate import of bundledassets package that was causing
compilation errors in PR #4318. The import was declared twice in
the same import block, causing "bundledassets redeclared" errors.

Fixes build issues in GitHub Actions for drag-and-drop zones feature.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Replace fmt.Printf debug statements with globalApplication.debug

Replace all fmt.Printf debug logging statements in drag-and-drop
functionality with proper globalApplication.debug calls. This provides:

- Consistent logging with the rest of the application
- Proper key-value structured logging
- Better integration with the application's logging system
- Cleaner debug output format

Changes:
- application_darwin.go: Replace 2 fmt.Printf calls
- webview_window.go: Replace 6 fmt.Printf calls
- webview_window_windows.go: Replace 13 fmt.Printf calls
- Remove unused fmt import from application_darwin.go

All debug messages maintain the same information but now use
structured logging with key-value pairs instead of printf formatting.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add nil checks to WindowEventContext methods

Ensure all WindowEventContext methods properly handle nil c.data
by initializing the map when it's nil. This prevents panics when
methods are called on contexts that haven't been properly initialized.

Changes:
- DroppedFiles(): Add nil check and map initialization
- setCoordinates(): Add nil check and map initialization
- setDropZoneDetails(): Add nil check and map initialization
- DropZoneDetails(): Add nil check and map initialization

All methods now follow the same pattern as setDroppedFiles()
where a nil data map is automatically initialized to prevent
runtime panics during drag-and-drop operations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update v3/pkg/application/webview_window_darwin.m

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* reinstate events docs.

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-08-04 20:40:19 +10:00

91 lines
2.3 KiB
Go

package application
import (
"github.com/wailsapp/wails/v3/pkg/events"
)
type Callback interface {
CallError(callID string, result string, isJSON bool)
CallResponse(callID string, result string)
DialogError(dialogID string, result string)
DialogResponse(dialogID string, result string, isJSON bool)
}
type Window interface {
Callback
Center()
Close()
DisableSizeConstraints()
DispatchWailsEvent(event *CustomEvent)
EmitEvent(name string, data ...any)
EnableSizeConstraints()
Error(message string, args ...any)
ExecJS(js string)
Focus()
ForceReload()
Fullscreen() Window
GetBorderSizes() *LRTB
GetScreen() (*Screen, error)
GetZoom() float64
HandleDragAndDropMessage(filenames []string, dropZone *DropZoneDetails)
InitiateFrontendDropProcessing(filenames []string, x int, y int)
HandleMessage(message string)
HandleWindowEvent(id uint)
Height() int
Hide() Window
HideMenuBar()
ID() uint
Info(message string, args ...any)
IsFocused() bool
IsFullscreen() bool
IsIgnoreMouseEvents() bool
IsMaximised() bool
IsMinimised() bool
HandleKeyEvent(acceleratorString string)
Maximise() Window
Minimise() Window
Name() string
OnWindowEvent(eventType events.WindowEventType, callback func(event *WindowEvent)) func()
OpenContextMenu(data *ContextMenuData)
Position() (int, int)
RelativePosition() (int, int)
Reload()
Resizable() bool
Restore()
Run()
SetPosition(x, y int)
SetAlwaysOnTop(b bool) Window
SetBackgroundColour(colour RGBA) Window
SetFrameless(frameless bool) Window
SetHTML(html string) Window
SetMinimiseButtonState(state ButtonState) Window
SetMaximiseButtonState(state ButtonState) Window
SetCloseButtonState(state ButtonState) Window
SetMaxSize(maxWidth, maxHeight int) Window
SetMinSize(minWidth, minHeight int) Window
SetRelativePosition(x, y int) Window
SetResizable(b bool) Window
SetIgnoreMouseEvents(ignore bool) Window
SetSize(width, height int) Window
SetTitle(title string) Window
SetURL(s string) Window
SetZoom(magnification float64) Window
Show() Window
ShowMenuBar()
Size() (width int, height int)
OpenDevTools()
ToggleFullscreen()
ToggleMaximise()
ToggleMenuBar()
ToggleFrameless()
UnFullscreen()
UnMaximise()
UnMinimise()
Width() int
Zoom()
ZoomIn()
ZoomOut()
ZoomReset() Window
SetMenu(menu *Menu)
SnapAssist()
}