5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 20:29:37 +08:00
wails/v3/examples/drag-n-drop/main.go
Etesam b30cea0de0
[V3] fix drag n drop example not running (#3742)
* Replaced customEventProcessor with EmitEvent

* 📝 Added bug fix entry to changelog
2024-09-13 05:41:06 +10:00

50 lines
1.1 KiB
Go

package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/events"
)
//go:embed assets
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "Drag-n-drop Demo",
Description: "A demo of the Drag-n-drop API",
Assets: application.AssetOptions{
Handler: application.BundledAssetFileServer(assets),
},
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
window := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Drag-n-drop Demo",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
EnableDragAndDrop: true,
})
window.OnWindowEvent(events.Common.WindowFilesDropped, func(event *application.WindowEvent) {
files := event.Context().DroppedFiles()
app.EmitEvent("files", files)
app.Logger.Info("Files Dropped!", "files", files)
})
err := app.Run()
if err != nil {
log.Fatal(err.Error())
}
}