Wails: kiosk mode - how to?

Created on 21 Dec 2019  路  5Comments  路  Source: wailsapp/wails

I'm sorry for write in bug-report. But I didn't found any places with discussion about wails.
How to build application in kiosk mode/fullscreen? I need some advice
Thnx

bug

All 5 comments

I used the wails:ready event to trigger going to full screen. Below is an adapted example although there may be some issues with formatting if you were to copy/paste it directly.
I used two structs where you could get by with a single one if you don't mind exposing any public functions on your struct to the frontend. I was attempting to keep functions only usable by the backend from being exposed to the frontend.

Hope this helps:

type App struct {
    log     *wails.CustomLogger
    runtime *wails.Runtime
}

func (a *App) Start() {
        a.log.Info("Application starting")
        a.runtime.Window.Fullscreen()
}

func (a *App) Shutdown() {
        a.log.Info("Application stopping")
}

// wailsinit is a struct who's sole purpose is to be bound by the Wails runtime
// It is intended to be used to avoid binding the App public functions.
type wailsinit struct {
    app *App
}

// WailsInit is automatically called by the Wails runtime during startup
// The callback is used to startup the processing code.
func (w *wailsinit) WailsInit(runtime *wails.Runtime) error {
    w.app.log = runtime.Log.New("Application")
    w.app.runtime = runtime
    runtime.Events.On("wails:ready", func(data ...interface{}) {
            a.Start()
    })
    return nil
}

func (w *wailsinit) WailsShutdown() {
    w.app.Shutdown()
}

func StartWails() {
    wapp := wails.CreateApp(&wails.AppConfig{
        Width:     1024,
        Height:    768,
        Title:     "Application Name",
        Resizable: true,
        JS:        js,
        CSS:       css,
        Colour:    "#131313",
    })
    wapp.Bind(&wailsinit{&App{}})
    wapp.Run()
}

Bear in mind this will not function in wails serve mode.

Here's a working simple application:

https://github.com/tmclane/wailskiosk

Wonderful! THanks!

Super interested to hear what you are using kiosk mode for @tmclane. For Wails 2, I'm looking to add fullscreen startup

Was this page helpful?
0 / 5 - 0 ratings