mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 16:40:41 +08:00
50 lines
1.1 KiB
Go
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())
|
|
}
|
|
}
|