mirror of
https://github.com/taigrr/wails.git
synced 2026-04-16 19:55:05 -07:00
Merge commit '25a157e6614739fbd4df1da3d11d46afe72ae9a8' as 'v2'
This commit is contained in:
75
v2/test/runtime/runtime.go
Normal file
75
v2/test/runtime/runtime.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
wails "github.com/leaanthony/wailsv2/v2"
|
||||
)
|
||||
|
||||
// RuntimeTest to test the runtimes
|
||||
type RuntimeTest struct {
|
||||
runtime *wails.Runtime
|
||||
}
|
||||
|
||||
// WailsInit is an initialisation method
|
||||
func (r *RuntimeTest) WailsInit(runtime *wails.Runtime) error {
|
||||
r.runtime = runtime
|
||||
println("Woohoo I'm here!")
|
||||
|
||||
// Set title!
|
||||
// runtime.Window.SetTitle("My App!")
|
||||
|
||||
r.runtime.Events.On("testevent", func(optionalParams ...interface{}) {
|
||||
println("Wooohoooo! I got called!")
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// WailsShutdown is called during shutdown
|
||||
func (r *RuntimeTest) WailsShutdown() {
|
||||
// This is a test
|
||||
println("WOOOOOOOOOOOOOO WailsShutdown CALLED")
|
||||
}
|
||||
|
||||
// EmitSingleEventNoParams will emit a single event with the given name and no params
|
||||
func (r *RuntimeTest) EmitSingleEventNoParams(name string) {
|
||||
r.runtime.Events.Emit(name)
|
||||
}
|
||||
|
||||
// EmitSingleEventWithOneParam will emit a single event with the given name
|
||||
func (r *RuntimeTest) EmitSingleEventWithOneParam(name string) {
|
||||
r.runtime.Events.Emit(name, 1)
|
||||
}
|
||||
|
||||
// RuntimeQuit will call the Runtime.Quit method
|
||||
func (r *RuntimeTest) RuntimeQuit() {
|
||||
r.runtime.Quit()
|
||||
}
|
||||
|
||||
// Fullscreen will call the Runtime.Fullscreen method
|
||||
func (r *RuntimeTest) Fullscreen() {
|
||||
r.runtime.Window.Fullscreen()
|
||||
}
|
||||
|
||||
// UnFullscreen will call the Runtime.UnFullscreen method
|
||||
func (r *RuntimeTest) UnFullscreen() {
|
||||
r.runtime.Window.UnFullscreen()
|
||||
}
|
||||
|
||||
// SetColour will call the Runtime.UnFullscreen method
|
||||
func (r *RuntimeTest) SetColour(colour string) {
|
||||
r.runtime.Window.SetColour(colour)
|
||||
}
|
||||
|
||||
// SelectFile will call the Runtime.Dialog.OpenFile method
|
||||
func (r *RuntimeTest) SelectFile() string {
|
||||
return r.runtime.Dialog.SelectFile("Open File Title")
|
||||
}
|
||||
|
||||
// SaveFile will call the Runtime.Dialog.SaveFile method
|
||||
func (r *RuntimeTest) SaveFile() string {
|
||||
return r.runtime.Dialog.SaveFile("Save File Title")
|
||||
}
|
||||
|
||||
// SelectDirectory will call the Runtime.Dialog.OpenDirectory method
|
||||
func (r *RuntimeTest) SelectDirectory() string {
|
||||
return r.runtime.Dialog.SelectDirectory("Open Directory Title")
|
||||
}
|
||||
Reference in New Issue
Block a user