Fixes focus issues, see #40.

This commit is contained in:
Nuno Cruces 2022-12-06 18:24:37 +00:00
parent ec524fa57e
commit 13c7dd3112
5 changed files with 19 additions and 19 deletions

View file

@ -25,9 +25,6 @@ func calendar(text string, opts options) (t time.Time, err error) {
} else {
data.Text = text
}
if opts.attach != nil {
data.Application = opts.attach
}
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
}

View file

@ -23,23 +23,26 @@ $.exit(-1)}
{'rgb('+res.map(x=>Math.round(x*255))+')'}
{{- end}}
{{define "common" -}}
{{if .WindowIcon}}{ObjC.import('Cocoa')
let nsapp=$.NSApplication.sharedApplication
let nsimg=$.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}})
nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular)
nsapp.setApplicationIconImage(nsimg)}{{end}}
{{- if .Application}}
try{var app=Application({{json .Application}})}catch{var app=Application.currentApplication()}
{{- else}}
var app=Application.currentApplication()
{{- end}}
app.includeStandardAdditions=true
{{if .WindowIcon}}{ObjC.import('Cocoa')
let nsapp=$.NSApplication.sharedApplication
let nsimg=$.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}})
nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular)
nsapp.setApplicationIconImage(nsimg)}{{end}}
app.activate()
{{- end}}
{{define "date" -}}
ObjC.import('Cocoa')
ObjC.import('stdio')
ObjC.import('stdlib')
{{template "common" .}}
var nsapp=$.NSApplication.sharedApplication
nsapp.setActivationPolicy($.NSApplicationActivationPolicyAccessory)
var date=$.NSDatePicker.alloc.init
date.setDatePickerStyle($.NSDatePickerStyleClockAndCalendar)
date.setDatePickerElements($.NSDatePickerElementFlagYearMonthDay)

View file

@ -1,3 +1,11 @@
{{if .WindowIcon}}{
ObjC.import('Cocoa')
let nsapp = $.NSApplication.sharedApplication
let nsimg = $.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}})
nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular)
nsapp.setApplicationIconImage(nsimg)
}{{end}}
{{- if .Application}}
try {
var app = Application({{json .Application}})
@ -8,11 +16,4 @@
var app = Application.currentApplication()
{{- end}}
app.includeStandardAdditions = true
{{if .WindowIcon}}{
ObjC.import('Cocoa')
let nsapp = $.NSApplication.sharedApplication
let nsimg = $.NSImage.alloc.initWithContentsOfFile({{json .WindowIcon}})
nsapp.setActivationPolicy($.NSApplicationActivationPolicyRegular)
nsapp.setApplicationIconImage(nsimg)
}{{end}}
app.activate()

View file

@ -1,6 +1,8 @@
ObjC.import('Cocoa')
ObjC.import('stdio')
ObjC.import('stdlib')
var nsapp = $.NSApplication.sharedApplication
nsapp.setActivationPolicy($.NSApplicationActivationPolicyAccessory)
{{template "common" .}}
var date = $.NSDatePicker.alloc.init

View file

@ -19,9 +19,6 @@ func progress(opts options) (ProgressDialog, error) {
if opts.maxValue >= 0 {
data.Total = &opts.maxValue
}
if opts.attach != nil {
data.Application = opts.attach
}
if i, ok := opts.windowIcon.(string); ok {
data.WindowIcon = i
}