5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 02:30:48 +08:00

Merge branch 'feature/asset-server-runtime'

# Conflicts:
#	v3/V3 Changes.md
#	v3/examples/events/assets/index.html
#	v3/examples/events/main.go
#	v3/internal/runtime/desktop/main.js
#	v3/internal/runtime/package-lock.json
#	v3/internal/runtime/package.json
#	v3/internal/runtime/runtime_debug_desktop_darwin.js
#	v3/internal/runtime/runtime_debug_desktop_linux.js
#	v3/internal/runtime/runtime_debug_desktop_windows.js
#	v3/internal/runtime/runtime_production_desktop_darwin.js
#	v3/internal/runtime/runtime_production_desktop_linux.js
#	v3/internal/runtime/runtime_production_desktop_windows.js
#	v3/pkg/application/application.go
#	v3/pkg/application/messageprocessor.go
#	v3/pkg/application/messageprocessor_window.go
#	v3/pkg/application/options_webview_window.go
#	v3/pkg/application/webview_window.go
#	v3/pkg/application/webview_window_darwin.go
#	v3/pkg/options/application.go
This commit is contained in:
Lea Anthony 2023-02-12 12:35:46 +11:00
commit b16b263820
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
64 changed files with 1274 additions and 910 deletions

View File

@ -6,16 +6,19 @@ github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keL
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/klauspost/cpuid/v2 v2.2.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/sftp v1.10.1 h1:VasscCm72135zRysgrJDKsntdmPN+OuU3+nnHYA9wyc=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=

View File

@ -7,13 +7,12 @@ import (
"github.com/wailsapp/wails/v3/examples/binding/services"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/options"
)
type localStruct struct{}
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Bind: []interface{}{
&localStruct{},
&services.GreetService{},

View File

@ -9,18 +9,16 @@ import (
"strconv"
"time"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/events"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "WebviewWindow Demo",
Description: "A demo of the WebviewWindow API",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
@ -67,45 +65,45 @@ func main() {
windowCounter++
})
if runtime.GOOS == "darwin" {
myMenu.Add("New WebviewWindow (TitleBarHiddenInset)").
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Mac: options.MacWindow{
TitleBar: options.TitleBarHiddenInset,
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInset,
InvisibleTitleBarHeight: 25,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetPosition(rand.Intn(1000), rand.Intn(800)).
SetHTML("<br/><br/><p>A TitleBarHiddenInset WebviewWindow example</p>").
SetHTML("<br/><br/><p>A MacTitleBarHiddenInset WebviewWindow example</p>").
Show()
windowCounter++
})
myMenu.Add("New WebviewWindow (TitleBarHiddenInsetUnified)").
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInsetUnified)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Mac: options.MacWindow{
TitleBar: options.TitleBarHiddenInsetUnified,
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetPosition(rand.Intn(1000), rand.Intn(800)).
SetHTML("<br/><br/><p>A TitleBarHiddenInsetUnified WebviewWindow example</p>").
SetHTML("<br/><br/><p>A MacTitleBarHiddenInsetUnified WebviewWindow example</p>").
Show()
windowCounter++
})
myMenu.Add("New WebviewWindow (TitleBarHidden)").
myMenu.Add("New WebviewWindow (MacTitleBarHidden)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Mac: options.MacWindow{
TitleBar: options.TitleBarHidden,
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHidden,
InvisibleTitleBarHeight: 25,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetPosition(rand.Intn(1000), rand.Intn(800)).
SetHTML("<br/><br/><p>A TitleBarHidden WebviewWindow example</p>").
SetHTML("<br/><br/><p>A MacTitleBarHidden WebviewWindow example</p>").
Show()
windowCounter++
})

View File

@ -5,17 +5,15 @@ import (
"log"
"time"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "Clipboard Demo",
Description: "A demo of the clipboard API",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>body{ text-align: center; color: white; background-color: rgba(0,0,0,0); user-select: none; -ms-user-select: none; -webkit-user-select: none; }</style>
<style>.file{ width: 100px; height: 100px; border: 3px solid black; }</style>
</head>
<body>
<h1>Events Demo</h1>
<br/>
<div class="file" id="123abc" data-contextmenu="test" data-contextmenu-data="1" draggable="true" ondragstart="dragstart()" ondragend="dragend()">
<h1>1</h1>
</div>
<div class="file" id="234abc" data-contextmenu="test" data-contextmenu-data="2" draggable="true" ondragstart="dragstart()" ondragend="dragend()">
<h1>2</h1>
</div>
<div class="file" id="345abc" data-contextmenu="test" data-contextmenu-data="3" draggable="true" ondragstart="dragstart()" ondragend="dragend()">
<h1>3</h1>
</div>
<div id="results"></div>
</body>
<script>
// window.addEventListener("dragstart", (event) =>
// event.dataTransfer.setData("text/plain", "This text may be dragged")
// );
</script>
</html>

View File

@ -0,0 +1,70 @@
package main
import (
"embed"
_ "embed"
"fmt"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed assets
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "Context Menu Demo",
Description: "A demo of the Context Menu API",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
mainWindow := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Context Menu Demo",
Assets: application.AssetOptions{
FS: assets,
},
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
})
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Context Menu Demo",
Assets: application.AssetOptions{
FS: assets,
},
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
})
contextMenu := app.NewMenu()
contextMenu.Add("Click Me").OnClick(func(data *application.Context) {
fmt.Printf("Context menu data: %+v\n", data.ContextMenuData())
})
globalContextMenu := app.NewMenu()
globalContextMenu.Add("Default context menu item").OnClick(func(data *application.Context) {
fmt.Printf("Context menu data: %+v\n", data.ContextMenuData())
})
// Registering the menu with a window will make it available to that window only
mainWindow.RegisterContextMenu("test", contextMenu)
// Registering the menu with the app will make it available to all windows
app.RegisterContextMenu("test", globalContextMenu)
err := app.Run()
if err != nil {
log.Fatal(err.Error())
}
}

View File

@ -7,17 +7,15 @@ import (
"runtime"
"strings"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "Dialogs Demo",
Description: "A demo of the dialogs API",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>body{ text-align: center; color: white; background-color: rgba(0,0,0,0); user-select: none; -ms-user-select: none; -webkit-user-select: none; }</style>
</head>
<body>
<h1>Drag-n-drop Demo</h1>
<br/>
Drop Files onto this window...
<div id="results"></div>
</body>
<script>
wails.Events.On("files", function(event) {
let resultsHTML = "";
event.data.forEach(function(file) {
resultsHTML += "<br/>" + file;
});
document.getElementById("results").innerHTML = resultsHTML;
})
</script>
</html>

View File

@ -0,0 +1,51 @@
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",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
window := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Drag-n-drop Demo",
Assets: application.AssetOptions{
FS: assets,
},
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
})
window.On(events.FilesDropped, func(ctx *application.WindowEventContext) {
files := ctx.DroppedFiles()
app.Events.Emit(&application.CustomEvent{
Name: "files",
Data: files,
})
log.Printf("[Go] FilesDropped received: %+v\n", files)
})
err := app.Run()
if err != nil {
log.Fatal(err.Error())
}
}

View File

@ -8,14 +8,13 @@ import (
"time"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/options"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "Menu Demo",
Description: "A demo of the menu system",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
@ -110,22 +109,22 @@ func main() {
mySystray.SetMenu(myMenu)
mySystray.SetIconPosition(application.NSImageLeading)
myWindow := app.NewWebviewWindowWithOptions(&options.WebviewWindow{
myWindow := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Kitchen Sink",
Width: 600,
Height: 400,
AlwaysOnTop: true,
DisableResize: false,
BackgroundColour: &options.RGBA{
BackgroundColour: &application.RGBA{
Red: 255,
Green: 255,
Blue: 255,
Alpha: 30,
},
StartState: options.WindowStateMaximised,
Mac: options.MacWindow{
Backdrop: options.MacBackdropTranslucent,
Appearance: options.NSAppearanceNameDarkAqua,
StartState: application.WindowStateMaximised,
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
Appearance: application.NSAppearanceNameDarkAqua,
},
})
/*
@ -185,14 +184,14 @@ func main() {
*/
var myWindow2 *application.WebviewWindow
var myWindow2Lock sync.RWMutex
myWindow2 = app.NewWebviewWindowWithOptions(&options.WebviewWindow{
myWindow2 = app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "#2",
Width: 1024,
Height: 768,
AlwaysOnTop: false,
URL: "https://google.com",
Mac: options.MacWindow{
Backdrop: options.MacBackdropTranslucent,
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
},
})
//myWindow2.On(events.Mac.WindowDidMove, func() {

View File

@ -4,17 +4,15 @@ import (
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "Menu Demo",
Description: "A demo of the menu system",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})

View File

@ -5,31 +5,29 @@ import (
"log"
"net/http"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "Plain",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
Assets: application.AssetOptions{
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`<html><head><title>Plain Bundle</title></head><body><div class="main"><h1>Plain Bundle</h1><p>This is a plain bundle. It has no frontend code but this was Served by the AssetServer's Handler</p></div></body></html>`))

View File

@ -5,17 +5,15 @@ import (
"log"
"runtime"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "Systray Demo",
Description: "A demo of the Systray API",
Mac: options.Mac{
ActivationPolicy: options.ActivationPolicyAccessory,
Mac: application.MacOptions{
ActivationPolicy: application.ActivationPolicyAccessory,
},
})

View File

@ -9,18 +9,16 @@ import (
"strconv"
"time"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/events"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "WebviewWindow Demo",
Description: "A demo of the WebviewWindow API",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
@ -58,56 +56,56 @@ func main() {
myMenu.Add("New Frameless WebviewWindow").
SetAccelerator("CmdOrCtrl+F").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
X: rand.Intn(1000),
Y: rand.Intn(800),
Frameless: true,
Mac: options.MacWindow{
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
},
}).Show()
windowCounter++
})
if runtime.GOOS == "darwin" {
myMenu.Add("New WebviewWindow (TitleBarHiddenInset)").
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInset)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Mac: options.MacWindow{
TitleBar: options.TitleBarHiddenInset,
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInset,
InvisibleTitleBarHeight: 25,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetPosition(rand.Intn(1000), rand.Intn(800)).
SetHTML("<br/><br/><p>A TitleBarHiddenInset WebviewWindow example</p>").
SetHTML("<br/><br/><p>A MacTitleBarHiddenInset WebviewWindow example</p>").
Show()
windowCounter++
})
myMenu.Add("New WebviewWindow (TitleBarHiddenInsetUnified)").
myMenu.Add("New WebviewWindow (MacTitleBarHiddenInsetUnified)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Mac: options.MacWindow{
TitleBar: options.TitleBarHiddenInsetUnified,
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetPosition(rand.Intn(1000), rand.Intn(800)).
SetHTML("<br/><br/><p>A TitleBarHiddenInsetUnified WebviewWindow example</p>").
SetHTML("<br/><br/><p>A MacTitleBarHiddenInsetUnified WebviewWindow example</p>").
Show()
windowCounter++
})
myMenu.Add("New WebviewWindow (TitleBarHidden)").
myMenu.Add("New WebviewWindow (MacTitleBarHidden)").
OnClick(func(ctx *application.Context) {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Mac: options.MacWindow{
TitleBar: options.TitleBarHidden,
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Mac: application.MacWindow{
TitleBar: application.MacTitleBarHidden,
InvisibleTitleBarHeight: 25,
},
}).
SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
SetPosition(rand.Intn(1000), rand.Intn(800)).
SetHTML("<br/><br/><p>A TitleBarHidden WebviewWindow example</p>").
SetHTML("<br/><br/><p>A MacTitleBarHidden WebviewWindow example</p>").
Show()
windowCounter++
})

View File

@ -7,8 +7,6 @@ import (
"math/rand"
"strconv"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
@ -16,11 +14,11 @@ import (
var assets embed.FS
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "WebviewWindow Javascript Demo",
Description: "A demo of the WebviewWindow API from Javascript",
Icon: nil,
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
@ -32,8 +30,8 @@ func main() {
windowCounter := 1
newWindow := func() {
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Assets: options.Assets{
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Assets: application.AssetOptions{
FS: assets,
},
}).

View File

@ -115,7 +115,7 @@ func findApplicationNewCalls(context *Context) {
return true
}
// Check struct literal is of type "options.Application"
// Check struct literal is of type "application.Options"
selectorExpr, ok := structLit.Type.(*ast.SelectorExpr)
if !ok {
return true

View File

@ -5,7 +5,6 @@ import (
"log"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/options"
)
type GreetService struct {
@ -22,7 +21,7 @@ type OtherService struct {
}
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Bind: []interface{}{
&GreetService{},
&OtherService{},

View File

@ -5,11 +5,10 @@ import (
"log"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/options"
)
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Bind: []interface{}{
&GreetService{},
&OtherService{},

View File

@ -5,7 +5,6 @@ import (
"log"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/options"
)
type GreetService struct {
@ -18,7 +17,7 @@ func (*GreetService) Greet(name string) string {
}
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Bind: []interface{}{
&GreetService{},
},

View File

@ -0,0 +1,32 @@
import {newRuntimeCaller} from "./runtime";
let call = newRuntimeCaller("contextmenu");
function openContextMenu(id, x, y, data) {
return call("OpenContextMenu", {id, x, y, data});
}
export function enableContextMenus(enabled) {
if (enabled) {
window.addEventListener('contextmenu', contextMenuHandler);
} else {
window.removeEventListener('contextmenu', contextMenuHandler);
}
}
function contextMenuHandler(event) {
processContextMenu(event.target, event);
}
function processContextMenu(element, event) {
let id = element.getAttribute('data-contextmenu');
if (id) {
event.preventDefault();
openContextMenu(id, event.clientX, event.clientY, element.getAttribute('data-contextmenu-data'));
} else {
let parent = element.parentElement;
if (parent) {
processContextMenu(parent, event);
}
}
}

View File

@ -5,8 +5,6 @@ import (
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
@ -14,25 +12,25 @@ import (
var assets embed.FS
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
Assets: application.AssetOptions{
FS: assets,
},
})

View File

@ -5,8 +5,6 @@ import (
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
@ -14,25 +12,25 @@ import (
var assets embed.FS
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
Assets: application.AssetOptions{
FS: assets,
},
})

View File

@ -5,8 +5,6 @@ import (
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
@ -14,25 +12,25 @@ import (
var assets embed.FS
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
Assets: application.AssetOptions{
FS: assets,
},
})

View File

@ -5,8 +5,6 @@ import (
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
@ -14,25 +12,25 @@ import (
var assets embed.FS
func main() {
app := application.New(options.Application{
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
Assets: application.AssetOptions{
FS: assets,
},
})

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -0,0 +1,43 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInset,
},
URL: "/",
Assets: application.AssetOptions{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,45 +0,0 @@
package main
import (
"embed"
_ "embed"
"log"
"github.com/wailsapp/wails/v3/pkg/options"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed frontend/dist
var assets embed.FS
func main() {
app := application.New(options.Application{
Name: "{{.ProjectName}}",
Description: "A demo of using raw HTML & CSS",
Mac: options.Mac{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(&options.WebviewWindow{
Title: "Plain Bundle",
CSS: `body { background-color: rgba(255, 255, 255, 0); } .main { color: white; margin: 20%; }`,
Mac: options.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: options.MacBackdropTranslucent,
TitleBar: options.TitleBarHiddenInset,
},
URL: "/",
Assets: options.Assets{
FS: assets,
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}

View File

@ -1,22 +1,17 @@
//go:build darwin
#import "app_delegate.h"
#import "../events/events.h"
extern bool hasListeners(unsigned int);
@implementation AppDelegate
- (void)dealloc
{
[super dealloc];
}
// Create the applicationShouldTerminateAfterLastWindowClosed: method
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
return self.shouldTerminateWhenLastWindowClosed;
}
// GENERATED EVENTS START
- (void)applicationDidBecomeActive:(NSNotification *)notification {
if( hasListeners(EventApplicationDidBecomeActive) ) {

View File

@ -230,6 +230,20 @@ func processURLRequest(windowID C.uint, wkUrlSchemeTask unsafe.Pointer) {
}
}
//export processDragItems
func processDragItems(windowID C.uint, arr **C.char, length C.int) {
var filenames []string
// Convert the C array to a Go slice
goSlice := (*[1 << 30]*C.char)(unsafe.Pointer(arr))[:length:length]
for _, str := range goSlice {
filenames = append(filenames, C.GoString(str))
}
windowDragAndDropBuffer <- &dragAndDropMessage{
windowId: uint(windowID),
filenames: filenames,
}
}
//export processMenuItemClick
func processMenuItemClick(menuID C.uint) {
menuItemClicked <- uint(menuID)

View File

@ -14,6 +14,7 @@ func newContext() *Context {
const (
clickedMenuItem string = "clickedMenuItem"
menuItemIsChecked string = "menuItemIsChecked"
contextMenuData string = "contextMenuData"
)
func (c *Context) ClickedMenuItem() *MenuItem {
@ -31,6 +32,9 @@ func (c *Context) IsChecked() bool {
}
return result.(bool)
}
func (c *Context) ContextMenuData() any {
return c.data[contextMenuData]
}
func (c *Context) withClickedMenuItem(menuItem *MenuItem) *Context {
c.data[clickedMenuItem] = menuItem
@ -40,3 +44,11 @@ func (c *Context) withClickedMenuItem(menuItem *MenuItem) *Context {
func (c *Context) withChecked(checked bool) {
c.data[menuItemIsChecked] = checked
}
func (c *Context) withContextMenuData(data *ContextMenuData) *Context {
if data == nil {
return c
}
c.data[contextMenuData] = data.Data
return c
}

View File

@ -0,0 +1,35 @@
package application
var blankWindowEventContext = &WindowEventContext{}
const (
// FilesDropped is the event name for when files are dropped on the window
droppedFiles = "droppedFiles"
)
type WindowEventContext struct {
// contains filtered or unexported fields
data map[string]any
}
func (c WindowEventContext) DroppedFiles() []string {
files, ok := c.data[droppedFiles]
if !ok {
return nil
}
result, ok := files.([]string)
if !ok {
return nil
}
return result
}
func (c WindowEventContext) setDroppedFiles(files []string) {
c.data[droppedFiles] = files
}
func newWindowEventContext() *WindowEventContext {
return &WindowEventContext{
data: make(map[string]any),
}
}

View File

@ -87,6 +87,12 @@ func (m *Menu) SetLabel(label string) {
m.label = label
}
func (m *Menu) setContextData(data *ContextMenuData) {
for _, item := range m.items {
item.setContextData(data)
}
}
func (a *App) NewMenu() *Menu {
return &Menu{}
}

View File

@ -41,16 +41,17 @@ type menuItemImpl interface {
}
type MenuItem struct {
id uint
label string
tooltip string
disabled bool
checked bool
submenu *Menu
callback func(*Context)
itemType menuItemType
accelerator *accelerator
role Role
id uint
label string
tooltip string
disabled bool
checked bool
submenu *Menu
callback func(*Context)
itemType menuItemType
accelerator *accelerator
role Role
contextMenuData *ContextMenuData
impl menuItemImpl
radioGroupMembers []*MenuItem
@ -187,7 +188,9 @@ func newServicesMenu() *MenuItem {
}
func (m *MenuItem) handleClick() {
var ctx = newContext().withClickedMenuItem(m)
var ctx = newContext().
withClickedMenuItem(m).
withContextMenuData(m.contextMenuData)
if m.itemType == checkbox {
m.checked = !m.checked
ctx.withChecked(m.checked)
@ -272,3 +275,10 @@ func (m *MenuItem) Tooltip() string {
func (m *MenuItem) Enabled() bool {
return !m.disabled
}
func (m *MenuItem) setContextData(data *ContextMenuData) {
m.contextMenuData = data
if m.submenu != nil {
m.submenu.setContextData(data)
}
}

View File

@ -0,0 +1,30 @@
package application
import (
"net/http"
)
type ContextMenuData struct {
Id string `json:"id"`
X int `json:"x"`
Y int `json:"y"`
Data any `json:"data"`
}
func (m *MessageProcessor) processContextMenuMethod(method string, rw http.ResponseWriter, _ *http.Request, window *WebviewWindow, params QueryParams) {
switch method {
case "OpenContextMenu":
var data ContextMenuData
err := params.ToStruct(&data)
if err != nil {
m.httpError(rw, "error parsing contextmenu message: %s", err.Error())
return
}
window.openContextMenu(&data)
m.ok(rw)
default:
m.httpError(rw, "Unknown clipboard method: %s", method)
}
}

View File

@ -0,0 +1,17 @@
package application
import (
"github.com/wailsapp/wails/v3/pkg/logger"
)
type Options struct {
Name string
Description string
Icon []byte
Mac MacOptions
Bind []any
Logger struct {
Silent bool
CustomLoggers []logger.Output
}
}

View File

@ -1,4 +1,4 @@
package options
package application
type ActivationPolicy int
@ -10,7 +10,7 @@ const (
ActivationPolicyProhibited
)
type Mac struct {
type MacOptions struct {
// ActivationPolicy is the activation policy for the application. Defaults to
// applicationActivationPolicyRegular.
ActivationPolicy ActivationPolicy
@ -44,13 +44,13 @@ const (
// MacWindow contains macOS specific options
type MacWindow struct {
Backdrop MacBackdrop
TitleBar TitleBar
TitleBar MacTitleBar
Appearance MacAppearanceType
InvisibleTitleBarHeight int
}
// TitleBar contains options for the Mac titlebar
type TitleBar struct {
// MacTitleBar contains options for the Mac titlebar
type MacTitleBar struct {
AppearsTransparent bool
Hide bool
HideTitle bool
@ -60,8 +60,8 @@ type TitleBar struct {
ToolbarStyle MacToolbarStyle
}
// TitleBarDefault results in the default Mac TitleBar
var TitleBarDefault = TitleBar{
// MacTitleBarDefault results in the default Mac MacTitleBar
var MacTitleBarDefault = MacTitleBar{
AppearsTransparent: false,
Hide: false,
HideTitle: false,
@ -72,10 +72,10 @@ var TitleBarDefault = TitleBar{
// Credit: Comments from Electron site
// TitleBarHidden results in a hidden title bar and a full size content window,
// MacTitleBarHidden results in a hidden title bar and a full size content window,
// yet the title bar still has the standard window controls (“traffic lights”)
// in the top left.
var TitleBarHidden = TitleBar{
var MacTitleBarHidden = MacTitleBar{
AppearsTransparent: true,
Hide: false,
HideTitle: true,
@ -84,9 +84,9 @@ var TitleBarHidden = TitleBar{
HideToolbarSeparator: false,
}
// TitleBarHiddenInset results in a hidden title bar with an alternative look where
// MacTitleBarHiddenInset results in a hidden title bar with an alternative look where
// the traffic light buttons are slightly more inset from the window edge.
var TitleBarHiddenInset = TitleBar{
var MacTitleBarHiddenInset = MacTitleBar{
AppearsTransparent: true,
Hide: false,
HideTitle: true,
@ -95,9 +95,9 @@ var TitleBarHiddenInset = TitleBar{
HideToolbarSeparator: true,
}
// TitleBarHiddenInsetUnified results in a hidden title bar with an alternative look where
// MacTitleBarHiddenInsetUnified results in a hidden title bar with an alternative look where
// the traffic light buttons are even more inset from the window edge.
var TitleBarHiddenInsetUnified = TitleBar{
var MacTitleBarHiddenInsetUnified = MacTitleBar{
AppearsTransparent: true,
Hide: false,
HideTitle: true,

View File

@ -0,0 +1,7 @@
//go:build darwin
#import <AppKit/AppKit.h>
@interface WebviewDrag : NSView <NSDraggingDestination>
@property unsigned int windowId;
@end

View File

@ -0,0 +1,59 @@
//go:build darwin
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import "webview_drag.h"
#import "../events/events.h"
extern void processDragItems(unsigned int windowId, char** arr, int length);
@implementation WebviewDrag
- (instancetype)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if (self) {
[self registerForDraggedTypes:@[NSFilenamesPboardType]];
}
return self;
}
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
NSPasteboard *pasteboard = [sender draggingPasteboard];
if ([[pasteboard types] containsObject:NSFilenamesPboardType]) {
processWindowEvent(self.windowId, EventWebViewDraggingEntered);
return NSDragOperationCopy;
}
return NSDragOperationNone;
}
- (void)draggingExited:(id<NSDraggingInfo>)sender {
NSLog(@"I am here!!!!");
}
- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender {
return YES;
}
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
NSPasteboard *pasteboard = [sender draggingPasteboard];
if ([[pasteboard types] containsObject:NSFilenamesPboardType]) {
NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
NSUInteger count = [files count];
char** cArray = (char**)malloc(count * sizeof(char*));
for (NSUInteger i = 0; i < count; i++) {
NSString* str = files[i];
cArray[i] = (char*)[str UTF8String];
}
processDragItems(self.windowId, cArray, (int)count);
free(cArray);
return YES;
}
return NO;
}
@end

View File

@ -16,7 +16,7 @@
@end
@interface WebviewWindowDelegate : NSObject <NSWindowDelegate, WKScriptMessageHandler, WKNavigationDelegate, WKURLSchemeHandler>
@interface WebviewWindowDelegate : NSObject <NSWindowDelegate, WKScriptMessageHandler, WKNavigationDelegate, WKURLSchemeHandler, NSDraggingDestination>
@property bool hideOnClose;
@property (retain) WKWebView* webView;
@ -29,7 +29,6 @@
- (void)handleLeftMouseUp:(NSWindow *)window;
- (void)handleLeftMouseDown:(NSEvent*)event;
@end

View File

@ -1,16 +1,12 @@
//go:build darwin
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import "webview_window.h"
#import "../events/events.h"
extern void processMessage(unsigned int, const char*);
extern void processURLRequest(unsigned int, void *);
extern bool hasListeners(unsigned int);
@implementation WebviewWindow
- (WebviewWindow*) initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation;
{
self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
@ -20,11 +16,9 @@ extern bool hasListeners(unsigned int);
[self setMovableByWindowBackground:YES];
return self;
}
- (BOOL)canBecomeKeyWindow {
return YES;
}
- (BOOL) canBecomeMainWindow {
return YES;
}
@ -38,9 +32,7 @@ extern bool hasListeners(unsigned int);
return YES;
}
@end
@implementation WebviewWindowDelegate
- (BOOL)windowShouldClose:(NSWindow *)sender {
if( self.hideOnClose ) {
[NSApp hide:nil];
@ -48,7 +40,6 @@ extern bool hasListeners(unsigned int);
}
return true;
}
// Handle script messages from the external bridge
- (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
NSString *m = message.body;
@ -83,11 +74,9 @@ extern bool hasListeners(unsigned int);
- (void)handleLeftMouseUp:(NSWindow *)window {
self.leftMouseEvent = nil;
}
- (void)webView:(nonnull WKWebView *)webView startURLSchemeTask:(nonnull id<WKURLSchemeTask>)urlSchemeTask {
processURLRequest(self.windowId, urlSchemeTask);
}
- (void)webView:(nonnull WKWebView *)webView stopURLSchemeTask:(nonnull id<WKURLSchemeTask>)urlSchemeTask {
NSInputStream *stream = urlSchemeTask.request.HTTPBodyStream;
if (stream) {
@ -97,7 +86,6 @@ extern bool hasListeners(unsigned int);
}
}
}
// GENERATED EVENTS START
- (void)windowDidBecomeKey:(NSNotification *)notification {
if( hasListeners(EventWindowDidBecomeKey) ) {
@ -561,5 +549,17 @@ extern bool hasListeners(unsigned int);
}
}
- (void)webView:(WKWebView *)webview draggingEntered:(WKNavigation *)navigation {
if( hasListeners(EventWebViewDraggingEntered) ) {
processWindowEvent(self.windowId, EventWebViewDraggingEntered);
}
}
- (void)webView:(WKWebView *)webview draggingPerformed:(WKNavigation *)navigation {
if( hasListeners(EventWebViewDraggingPerformed) ) {
processWindowEvent(self.windowId, EventWebViewDraggingPerformed);
}
}
// GENERATED EVENTS END
@end

View File

@ -3,6 +3,10 @@ package events
type ApplicationEventType uint
type WindowEventType uint
const (
FilesDropped WindowEventType = iota
)
var Mac = newMacEvents()
type macEvents struct {
@ -126,129 +130,133 @@ type macEvents struct {
WebViewDidReceiveServerRedirectForProvisionalNavigation WindowEventType
WebViewDidFinishNavigation WindowEventType
WebViewDidCommitNavigation WindowEventType
WebViewDraggingEntered WindowEventType
WebViewDraggingPerformed WindowEventType
}
func newMacEvents() macEvents {
return macEvents{
ApplicationDidBecomeActive: 0,
ApplicationDidChangeBackingProperties: 1,
ApplicationDidChangeEffectiveAppearance: 2,
ApplicationDidChangeIcon: 3,
ApplicationDidChangeOcclusionState: 4,
ApplicationDidChangeScreenParameters: 5,
ApplicationDidChangeStatusBarFrame: 6,
ApplicationDidChangeStatusBarOrientation: 7,
ApplicationDidFinishLaunching: 8,
ApplicationDidHide: 9,
ApplicationDidResignActive: 10,
ApplicationDidUnhide: 11,
ApplicationDidUpdate: 12,
ApplicationWillBecomeActive: 13,
ApplicationWillFinishLaunching: 14,
ApplicationWillHide: 15,
ApplicationWillResignActive: 16,
ApplicationWillTerminate: 17,
ApplicationWillUnhide: 18,
ApplicationWillUpdate: 19,
WindowDidBecomeKey: 20,
WindowDidBecomeMain: 21,
WindowDidBeginSheet: 22,
WindowDidChangeAlpha: 23,
WindowDidChangeBackingLocation: 24,
WindowDidChangeBackingProperties: 25,
WindowDidChangeCollectionBehavior: 26,
WindowDidChangeEffectiveAppearance: 27,
WindowDidChangeOcclusionState: 28,
WindowDidChangeOrderingMode: 29,
WindowDidChangeScreen: 30,
WindowDidChangeScreenParameters: 31,
WindowDidChangeScreenProfile: 32,
WindowDidChangeScreenSpace: 33,
WindowDidChangeScreenSpaceProperties: 34,
WindowDidChangeSharingType: 35,
WindowDidChangeSpace: 36,
WindowDidChangeSpaceOrderingMode: 37,
WindowDidChangeTitle: 38,
WindowDidChangeToolbar: 39,
WindowDidChangeVisibility: 40,
WindowDidClose: 41,
WindowDidDeminiaturize: 42,
WindowDidEndSheet: 43,
WindowDidEnterFullScreen: 44,
WindowDidEnterVersionBrowser: 45,
WindowDidExitFullScreen: 46,
WindowDidExitVersionBrowser: 47,
WindowDidExpose: 48,
WindowDidFocus: 49,
WindowDidMiniaturize: 50,
WindowDidMove: 51,
WindowDidOrderOffScreen: 52,
WindowDidOrderOnScreen: 53,
WindowDidResignKey: 54,
WindowDidResignMain: 55,
WindowDidResize: 56,
WindowDidUnfocus: 57,
WindowDidUpdate: 58,
WindowDidUpdateAlpha: 59,
WindowDidUpdateCollectionBehavior: 60,
WindowDidUpdateCollectionProperties: 61,
WindowDidUpdateShadow: 62,
WindowDidUpdateTitle: 63,
WindowDidUpdateToolbar: 64,
WindowDidUpdateVisibility: 65,
WindowWillBecomeKey: 66,
WindowWillBecomeMain: 67,
WindowWillBeginSheet: 68,
WindowWillChangeOrderingMode: 69,
WindowWillClose: 70,
WindowWillDeminiaturize: 71,
WindowWillEnterFullScreen: 72,
WindowWillEnterVersionBrowser: 73,
WindowWillExitFullScreen: 74,
WindowWillExitVersionBrowser: 75,
WindowWillFocus: 76,
WindowWillMiniaturize: 77,
WindowWillMove: 78,
WindowWillOrderOffScreen: 79,
WindowWillOrderOnScreen: 80,
WindowWillResignMain: 81,
WindowWillResize: 82,
WindowWillUnfocus: 83,
WindowWillUpdate: 84,
WindowWillUpdateAlpha: 85,
WindowWillUpdateCollectionBehavior: 86,
WindowWillUpdateCollectionProperties: 87,
WindowWillUpdateShadow: 88,
WindowWillUpdateTitle: 89,
WindowWillUpdateToolbar: 90,
WindowWillUpdateVisibility: 91,
WindowWillUseStandardFrame: 92,
MenuWillOpen: 93,
MenuDidOpen: 94,
MenuDidClose: 95,
MenuWillSendAction: 96,
MenuDidSendAction: 97,
MenuWillHighlightItem: 98,
MenuDidHighlightItem: 99,
MenuWillDisplayItem: 100,
MenuDidDisplayItem: 101,
MenuWillAddItem: 102,
MenuDidAddItem: 103,
MenuWillRemoveItem: 104,
MenuDidRemoveItem: 105,
MenuWillBeginTracking: 106,
MenuDidBeginTracking: 107,
MenuWillEndTracking: 108,
MenuDidEndTracking: 109,
MenuWillUpdate: 110,
MenuDidUpdate: 111,
MenuWillPopUp: 112,
MenuDidPopUp: 113,
MenuWillSendActionToItem: 114,
MenuDidSendActionToItem: 115,
WebViewDidStartProvisionalNavigation: 116,
WebViewDidReceiveServerRedirectForProvisionalNavigation: 117,
WebViewDidFinishNavigation: 118,
WebViewDidCommitNavigation: 119,
ApplicationDidBecomeActive: 1024,
ApplicationDidChangeBackingProperties: 1025,
ApplicationDidChangeEffectiveAppearance: 1026,
ApplicationDidChangeIcon: 1027,
ApplicationDidChangeOcclusionState: 1028,
ApplicationDidChangeScreenParameters: 1029,
ApplicationDidChangeStatusBarFrame: 1030,
ApplicationDidChangeStatusBarOrientation: 1031,
ApplicationDidFinishLaunching: 1032,
ApplicationDidHide: 1033,
ApplicationDidResignActive: 1034,
ApplicationDidUnhide: 1035,
ApplicationDidUpdate: 1036,
ApplicationWillBecomeActive: 1037,
ApplicationWillFinishLaunching: 1038,
ApplicationWillHide: 1039,
ApplicationWillResignActive: 1040,
ApplicationWillTerminate: 1041,
ApplicationWillUnhide: 1042,
ApplicationWillUpdate: 1043,
WindowDidBecomeKey: 1044,
WindowDidBecomeMain: 1045,
WindowDidBeginSheet: 1046,
WindowDidChangeAlpha: 1047,
WindowDidChangeBackingLocation: 1048,
WindowDidChangeBackingProperties: 1049,
WindowDidChangeCollectionBehavior: 1050,
WindowDidChangeEffectiveAppearance: 1051,
WindowDidChangeOcclusionState: 1052,
WindowDidChangeOrderingMode: 1053,
WindowDidChangeScreen: 1054,
WindowDidChangeScreenParameters: 1055,
WindowDidChangeScreenProfile: 1056,
WindowDidChangeScreenSpace: 1057,
WindowDidChangeScreenSpaceProperties: 1058,
WindowDidChangeSharingType: 1059,
WindowDidChangeSpace: 1060,
WindowDidChangeSpaceOrderingMode: 1061,
WindowDidChangeTitle: 1062,
WindowDidChangeToolbar: 1063,
WindowDidChangeVisibility: 1064,
WindowDidClose: 1065,
WindowDidDeminiaturize: 1066,
WindowDidEndSheet: 1067,
WindowDidEnterFullScreen: 1068,
WindowDidEnterVersionBrowser: 1069,
WindowDidExitFullScreen: 1070,
WindowDidExitVersionBrowser: 1071,
WindowDidExpose: 1072,
WindowDidFocus: 1073,
WindowDidMiniaturize: 1074,
WindowDidMove: 1075,
WindowDidOrderOffScreen: 1076,
WindowDidOrderOnScreen: 1077,
WindowDidResignKey: 1078,
WindowDidResignMain: 1079,
WindowDidResize: 1080,
WindowDidUnfocus: 1081,
WindowDidUpdate: 1082,
WindowDidUpdateAlpha: 1083,
WindowDidUpdateCollectionBehavior: 1084,
WindowDidUpdateCollectionProperties: 1085,
WindowDidUpdateShadow: 1086,
WindowDidUpdateTitle: 1087,
WindowDidUpdateToolbar: 1088,
WindowDidUpdateVisibility: 1089,
WindowWillBecomeKey: 1090,
WindowWillBecomeMain: 1091,
WindowWillBeginSheet: 1092,
WindowWillChangeOrderingMode: 1093,
WindowWillClose: 1094,
WindowWillDeminiaturize: 1095,
WindowWillEnterFullScreen: 1096,
WindowWillEnterVersionBrowser: 1097,
WindowWillExitFullScreen: 1098,
WindowWillExitVersionBrowser: 1099,
WindowWillFocus: 1100,
WindowWillMiniaturize: 1101,
WindowWillMove: 1102,
WindowWillOrderOffScreen: 1103,
WindowWillOrderOnScreen: 1104,
WindowWillResignMain: 1105,
WindowWillResize: 1106,
WindowWillUnfocus: 1107,
WindowWillUpdate: 1108,
WindowWillUpdateAlpha: 1109,
WindowWillUpdateCollectionBehavior: 1110,
WindowWillUpdateCollectionProperties: 1111,
WindowWillUpdateShadow: 1112,
WindowWillUpdateTitle: 1113,
WindowWillUpdateToolbar: 1114,
WindowWillUpdateVisibility: 1115,
WindowWillUseStandardFrame: 1116,
MenuWillOpen: 1117,
MenuDidOpen: 1118,
MenuDidClose: 1119,
MenuWillSendAction: 1120,
MenuDidSendAction: 1121,
MenuWillHighlightItem: 1122,
MenuDidHighlightItem: 1123,
MenuWillDisplayItem: 1124,
MenuDidDisplayItem: 1125,
MenuWillAddItem: 1126,
MenuDidAddItem: 1127,
MenuWillRemoveItem: 1128,
MenuDidRemoveItem: 1129,
MenuWillBeginTracking: 1130,
MenuDidBeginTracking: 1131,
MenuWillEndTracking: 1132,
MenuDidEndTracking: 1133,
MenuWillUpdate: 1134,
MenuDidUpdate: 1135,
MenuWillPopUp: 1136,
MenuDidPopUp: 1137,
MenuWillSendActionToItem: 1138,
MenuDidSendActionToItem: 1139,
WebViewDidStartProvisionalNavigation: 1140,
WebViewDidReceiveServerRedirectForProvisionalNavigation: 1141,
WebViewDidFinishNavigation: 1142,
WebViewDidCommitNavigation: 1143,
WebViewDraggingEntered: 1144,
WebViewDraggingPerformed: 1145,
}
}

View File

@ -6,128 +6,130 @@
extern void processApplicationEvent(unsigned int);
extern void processWindowEvent(unsigned int, unsigned int);
#define EventApplicationDidBecomeActive 0
#define EventApplicationDidChangeBackingProperties 1
#define EventApplicationDidChangeEffectiveAppearance 2
#define EventApplicationDidChangeIcon 3
#define EventApplicationDidChangeOcclusionState 4
#define EventApplicationDidChangeScreenParameters 5
#define EventApplicationDidChangeStatusBarFrame 6
#define EventApplicationDidChangeStatusBarOrientation 7
#define EventApplicationDidFinishLaunching 8
#define EventApplicationDidHide 9
#define EventApplicationDidResignActive 10
#define EventApplicationDidUnhide 11
#define EventApplicationDidUpdate 12
#define EventApplicationWillBecomeActive 13
#define EventApplicationWillFinishLaunching 14
#define EventApplicationWillHide 15
#define EventApplicationWillResignActive 16
#define EventApplicationWillTerminate 17
#define EventApplicationWillUnhide 18
#define EventApplicationWillUpdate 19
#define EventWindowDidBecomeKey 20
#define EventWindowDidBecomeMain 21
#define EventWindowDidBeginSheet 22
#define EventWindowDidChangeAlpha 23
#define EventWindowDidChangeBackingLocation 24
#define EventWindowDidChangeBackingProperties 25
#define EventWindowDidChangeCollectionBehavior 26
#define EventWindowDidChangeEffectiveAppearance 27
#define EventWindowDidChangeOcclusionState 28
#define EventWindowDidChangeOrderingMode 29
#define EventWindowDidChangeScreen 30
#define EventWindowDidChangeScreenParameters 31
#define EventWindowDidChangeScreenProfile 32
#define EventWindowDidChangeScreenSpace 33
#define EventWindowDidChangeScreenSpaceProperties 34
#define EventWindowDidChangeSharingType 35
#define EventWindowDidChangeSpace 36
#define EventWindowDidChangeSpaceOrderingMode 37
#define EventWindowDidChangeTitle 38
#define EventWindowDidChangeToolbar 39
#define EventWindowDidChangeVisibility 40
#define EventWindowDidClose 41
#define EventWindowDidDeminiaturize 42
#define EventWindowDidEndSheet 43
#define EventWindowDidEnterFullScreen 44
#define EventWindowDidEnterVersionBrowser 45
#define EventWindowDidExitFullScreen 46
#define EventWindowDidExitVersionBrowser 47
#define EventWindowDidExpose 48
#define EventWindowDidFocus 49
#define EventWindowDidMiniaturize 50
#define EventWindowDidMove 51
#define EventWindowDidOrderOffScreen 52
#define EventWindowDidOrderOnScreen 53
#define EventWindowDidResignKey 54
#define EventWindowDidResignMain 55
#define EventWindowDidResize 56
#define EventWindowDidUnfocus 57
#define EventWindowDidUpdate 58
#define EventWindowDidUpdateAlpha 59
#define EventWindowDidUpdateCollectionBehavior 60
#define EventWindowDidUpdateCollectionProperties 61
#define EventWindowDidUpdateShadow 62
#define EventWindowDidUpdateTitle 63
#define EventWindowDidUpdateToolbar 64
#define EventWindowDidUpdateVisibility 65
#define EventWindowWillBecomeKey 66
#define EventWindowWillBecomeMain 67
#define EventWindowWillBeginSheet 68
#define EventWindowWillChangeOrderingMode 69
#define EventWindowWillClose 70
#define EventWindowWillDeminiaturize 71
#define EventWindowWillEnterFullScreen 72
#define EventWindowWillEnterVersionBrowser 73
#define EventWindowWillExitFullScreen 74
#define EventWindowWillExitVersionBrowser 75
#define EventWindowWillFocus 76
#define EventWindowWillMiniaturize 77
#define EventWindowWillMove 78
#define EventWindowWillOrderOffScreen 79
#define EventWindowWillOrderOnScreen 80
#define EventWindowWillResignMain 81
#define EventWindowWillResize 82
#define EventWindowWillUnfocus 83
#define EventWindowWillUpdate 84
#define EventWindowWillUpdateAlpha 85
#define EventWindowWillUpdateCollectionBehavior 86
#define EventWindowWillUpdateCollectionProperties 87
#define EventWindowWillUpdateShadow 88
#define EventWindowWillUpdateTitle 89
#define EventWindowWillUpdateToolbar 90
#define EventWindowWillUpdateVisibility 91
#define EventWindowWillUseStandardFrame 92
#define EventMenuWillOpen 93
#define EventMenuDidOpen 94
#define EventMenuDidClose 95
#define EventMenuWillSendAction 96
#define EventMenuDidSendAction 97
#define EventMenuWillHighlightItem 98
#define EventMenuDidHighlightItem 99
#define EventMenuWillDisplayItem 100
#define EventMenuDidDisplayItem 101
#define EventMenuWillAddItem 102
#define EventMenuDidAddItem 103
#define EventMenuWillRemoveItem 104
#define EventMenuDidRemoveItem 105
#define EventMenuWillBeginTracking 106
#define EventMenuDidBeginTracking 107
#define EventMenuWillEndTracking 108
#define EventMenuDidEndTracking 109
#define EventMenuWillUpdate 110
#define EventMenuDidUpdate 111
#define EventMenuWillPopUp 112
#define EventMenuDidPopUp 113
#define EventMenuWillSendActionToItem 114
#define EventMenuDidSendActionToItem 115
#define EventWebViewDidStartProvisionalNavigation 116
#define EventWebViewDidReceiveServerRedirectForProvisionalNavigation 117
#define EventWebViewDidFinishNavigation 118
#define EventWebViewDidCommitNavigation 119
#define EventApplicationDidBecomeActive 1024
#define EventApplicationDidChangeBackingProperties 1025
#define EventApplicationDidChangeEffectiveAppearance 1026
#define EventApplicationDidChangeIcon 1027
#define EventApplicationDidChangeOcclusionState 1028
#define EventApplicationDidChangeScreenParameters 1029
#define EventApplicationDidChangeStatusBarFrame 1030
#define EventApplicationDidChangeStatusBarOrientation 1031
#define EventApplicationDidFinishLaunching 1032
#define EventApplicationDidHide 1033
#define EventApplicationDidResignActive 1034
#define EventApplicationDidUnhide 1035
#define EventApplicationDidUpdate 1036
#define EventApplicationWillBecomeActive 1037
#define EventApplicationWillFinishLaunching 1038
#define EventApplicationWillHide 1039
#define EventApplicationWillResignActive 1040
#define EventApplicationWillTerminate 1041
#define EventApplicationWillUnhide 1042
#define EventApplicationWillUpdate 1043
#define EventWindowDidBecomeKey 1044
#define EventWindowDidBecomeMain 1045
#define EventWindowDidBeginSheet 1046
#define EventWindowDidChangeAlpha 1047
#define EventWindowDidChangeBackingLocation 1048
#define EventWindowDidChangeBackingProperties 1049
#define EventWindowDidChangeCollectionBehavior 1050
#define EventWindowDidChangeEffectiveAppearance 1051
#define EventWindowDidChangeOcclusionState 1052
#define EventWindowDidChangeOrderingMode 1053
#define EventWindowDidChangeScreen 1054
#define EventWindowDidChangeScreenParameters 1055
#define EventWindowDidChangeScreenProfile 1056
#define EventWindowDidChangeScreenSpace 1057
#define EventWindowDidChangeScreenSpaceProperties 1058
#define EventWindowDidChangeSharingType 1059
#define EventWindowDidChangeSpace 1060
#define EventWindowDidChangeSpaceOrderingMode 1061
#define EventWindowDidChangeTitle 1062
#define EventWindowDidChangeToolbar 1063
#define EventWindowDidChangeVisibility 1064
#define EventWindowDidClose 1065
#define EventWindowDidDeminiaturize 1066
#define EventWindowDidEndSheet 1067
#define EventWindowDidEnterFullScreen 1068
#define EventWindowDidEnterVersionBrowser 1069
#define EventWindowDidExitFullScreen 1070
#define EventWindowDidExitVersionBrowser 1071
#define EventWindowDidExpose 1072
#define EventWindowDidFocus 1073
#define EventWindowDidMiniaturize 1074
#define EventWindowDidMove 1075
#define EventWindowDidOrderOffScreen 1076
#define EventWindowDidOrderOnScreen 1077
#define EventWindowDidResignKey 1078
#define EventWindowDidResignMain 1079
#define EventWindowDidResize 1080
#define EventWindowDidUnfocus 1081
#define EventWindowDidUpdate 1082
#define EventWindowDidUpdateAlpha 1083
#define EventWindowDidUpdateCollectionBehavior 1084
#define EventWindowDidUpdateCollectionProperties 1085
#define EventWindowDidUpdateShadow 1086
#define EventWindowDidUpdateTitle 1087
#define EventWindowDidUpdateToolbar 1088
#define EventWindowDidUpdateVisibility 1089
#define EventWindowWillBecomeKey 1090
#define EventWindowWillBecomeMain 1091
#define EventWindowWillBeginSheet 1092
#define EventWindowWillChangeOrderingMode 1093
#define EventWindowWillClose 1094
#define EventWindowWillDeminiaturize 1095
#define EventWindowWillEnterFullScreen 1096
#define EventWindowWillEnterVersionBrowser 1097
#define EventWindowWillExitFullScreen 1098
#define EventWindowWillExitVersionBrowser 1099
#define EventWindowWillFocus 1100
#define EventWindowWillMiniaturize 1101
#define EventWindowWillMove 1102
#define EventWindowWillOrderOffScreen 1103
#define EventWindowWillOrderOnScreen 1104
#define EventWindowWillResignMain 1105
#define EventWindowWillResize 1106
#define EventWindowWillUnfocus 1107
#define EventWindowWillUpdate 1108
#define EventWindowWillUpdateAlpha 1109
#define EventWindowWillUpdateCollectionBehavior 1110
#define EventWindowWillUpdateCollectionProperties 1111
#define EventWindowWillUpdateShadow 1112
#define EventWindowWillUpdateTitle 1113
#define EventWindowWillUpdateToolbar 1114
#define EventWindowWillUpdateVisibility 1115
#define EventWindowWillUseStandardFrame 1116
#define EventMenuWillOpen 1117
#define EventMenuDidOpen 1118
#define EventMenuDidClose 1119
#define EventMenuWillSendAction 1120
#define EventMenuDidSendAction 1121
#define EventMenuWillHighlightItem 1122
#define EventMenuDidHighlightItem 1123
#define EventMenuWillDisplayItem 1124
#define EventMenuDidDisplayItem 1125
#define EventMenuWillAddItem 1126
#define EventMenuDidAddItem 1127
#define EventMenuWillRemoveItem 1128
#define EventMenuDidRemoveItem 1129
#define EventMenuWillBeginTracking 1130
#define EventMenuDidBeginTracking 1131
#define EventMenuWillEndTracking 1132
#define EventMenuDidEndTracking 1133
#define EventMenuWillUpdate 1134
#define EventMenuDidUpdate 1135
#define EventMenuWillPopUp 1136
#define EventMenuDidPopUp 1137
#define EventMenuWillSendActionToItem 1138
#define EventMenuDidSendActionToItem 1139
#define EventWebViewDidStartProvisionalNavigation 1140
#define EventWebViewDidReceiveServerRedirectForProvisionalNavigation 1141
#define EventWebViewDidFinishNavigation 1142
#define EventWebViewDidCommitNavigation 1143
#define EventWebViewDraggingEntered 1144
#define EventWebViewDraggingPerformed 1145
#define MAX_EVENTS 120
#define MAX_EVENTS 1146
#endif

View File

@ -118,4 +118,7 @@ mac:WebViewDidStartProvisionalNavigation
mac:WebViewDidReceiveServerRedirectForProvisionalNavigation
mac:WebViewDidFinishNavigation
mac:WebViewDidCommitNavigation
mac:WebViewDraggingEntered
mac:WebViewDraggingPerformed

View File

@ -12,6 +12,10 @@ var eventsGo = `package events
type ApplicationEventType uint
type WindowEventType uint
const (
FilesDropped WindowEventType = iota
)
var Mac = newMacEvents()
type macEvents struct {
@ -54,6 +58,9 @@ func main() {
// Loop over each line in the file
for id, line = range bytes.Split(eventNames, []byte{'\n'}) {
// First 1024 is reserved
id = id + 1024
// Skip empty lines
if len(line) == 0 {
continue
@ -143,7 +150,7 @@ func main() {
}
// Load the window_delegate.m file
windowDelegate, err := os.ReadFile("../../pkg/application/window_delegate.m")
windowDelegate, err := os.ReadFile("../../pkg/application/webview_window.m")
if err != nil {
panic(err)
}
@ -173,7 +180,7 @@ func main() {
}
}
}
err = os.WriteFile("../../pkg/application/window_delegate.m", buffer.Bytes(), 0755)
err = os.WriteFile("../../pkg/application/webview_window.m", buffer.Bytes(), 0755)
if err != nil {
panic(err)
}