mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-06 16:30:22 +08:00

* darwin: add ApplicationShouldHandleReopen * docs: update changelog with mr id * events: update id * feat: always return true * Merge v3-alpha and regenerate events * darwin: allow pass nsdirectory to processApplicationEvent --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
package application
|
|
|
|
var blankApplicationEventContext = &ApplicationEventContext{}
|
|
|
|
const (
|
|
openedFiles = "openedFiles"
|
|
)
|
|
|
|
type ApplicationEventContext struct {
|
|
// contains filtered or unexported fields
|
|
data map[string]any
|
|
}
|
|
|
|
func (c ApplicationEventContext) OpenedFiles() []string {
|
|
files, ok := c.data[openedFiles]
|
|
if !ok {
|
|
return nil
|
|
}
|
|
result, ok := files.([]string)
|
|
if !ok {
|
|
return nil
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (c ApplicationEventContext) setOpenedFiles(files []string) {
|
|
c.data[openedFiles] = files
|
|
}
|
|
|
|
func (c ApplicationEventContext) setIsDarkMode(mode bool) {
|
|
c.data["isDarkMode"] = mode
|
|
}
|
|
|
|
func (c ApplicationEventContext) getBool(key string) bool {
|
|
mode, ok := c.data[key]
|
|
if !ok {
|
|
return false
|
|
}
|
|
result, ok := mode.(bool)
|
|
if !ok {
|
|
return false
|
|
}
|
|
return result
|
|
}
|
|
|
|
func (c ApplicationEventContext) IsDarkMode() bool {
|
|
return c.getBool("isDarkMode")
|
|
}
|
|
|
|
func (c ApplicationEventContext) HasVisibleWindows() bool {
|
|
return c.getBool("hasVisibleWindows")
|
|
}
|
|
|
|
func (c ApplicationEventContext) setData(data map[string]any) {
|
|
c.data = data
|
|
}
|
|
|
|
func newApplicationEventContext() *ApplicationEventContext {
|
|
return &ApplicationEventContext{
|
|
data: make(map[string]any),
|
|
}
|
|
}
|