kemoforge/internal/KFEditor/Templates/CustomFunction/CustomFunction.got

41 lines
1.1 KiB
Plaintext

package CustomFunction
import (
"log"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"g.r-io.lu/shynd/kemoforge/pkg/KFData"
"g.r-io.lu/shynd/kemoforge/pkg/KFData/KFObjects/KFFunction"
)
// Import is a function used to allow importing of the custom function package
// while still allowing the package to be used normally and not be yelled at by the compiler
func Import() {}
func init() {
log.Printf("Registering ExampleFunction")
customFunction := KFFunction.Function{
Name: "ExampleFunction",
Type: "CustomFunction.ExampleFunction",
RequiredArgs: KFData.NewNFInterfaceMap(),
OptionalArgs: KFData.NewNFInterfaceMap(),
}
customFunction.Register(ExampleFunctionHandler)
}
func ExampleFunctionHandler(window fyne.Window, args *KFData.NFInterfaceMap) (*KFData.NFInterfaceMap, error) {
//Get the message from the args
var message string
err := args.Get("message", &message)
if err != nil {
return nil, err
}
//Do something
log.Println("Example button was pressed!")
dialog.ShowInformation("Example", "Example button was pressed!\n Message: "+message, window)
return args, nil
}