- Add events that wrap vugu.DOMEvent - Add event example for the input field component - Rename handleChange to handleInput - Forward any oninput, onkeydown, onkeypress or onkeyup events to event listeners
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.d3nexus.de/Dadido3/D3vugu-components/components/input"
|
|
"git.d3nexus.de/Dadido3/D3vugu-components/components/overlay"
|
|
"git.d3nexus.de/Dadido3/D3vugu-components/icons"
|
|
"github.com/vugu/vugu"
|
|
)
|
|
|
|
type PageInput struct {
|
|
overlay.OverlayContainerRef
|
|
|
|
button1Counter int `vugu:"data"`
|
|
button4Bool bool `vugu:"data"`
|
|
|
|
radioButton1 string `vugu:"data"`
|
|
|
|
checkBox1 bool `vugu:"data"`
|
|
checkBox2 bool `vugu:"data"`
|
|
|
|
inputField1String string `vugu:"data"`
|
|
inputField2Int int `vugu:"data"`
|
|
inputField3Float float64 `vugu:"data"`
|
|
inputField4String string `vugu:"data"`
|
|
inputField5String string `vugu:"data"`
|
|
inputField5Bool bool `vugu:"data"`
|
|
inputField6Bool bool `vugu:"data"`
|
|
inputField7Time time.Time `vugu:"data"`
|
|
inputField8String string `vugu:"data"`
|
|
|
|
dropdown1Slice []string `vugu:"data"`
|
|
dropdown1Index int `vugu:"data"`
|
|
|
|
tags1Slice []string `vugu:"data"`
|
|
|
|
textArea1 string `vugu:"data"`
|
|
}
|
|
|
|
func (c *PageInput) Init(ctx vugu.InitCtx) {
|
|
c.radioButton1 = "B"
|
|
c.checkBox2 = true
|
|
c.inputField7Time = time.Now()
|
|
c.dropdown1Slice = []string{"This", "is", "a", "list", "of", "things!"}
|
|
c.tags1Slice = []string{"some", "tags"}
|
|
c.textArea1 = "This is some example text\n\nAnd some line-breaks."
|
|
}
|
|
|
|
func (c *PageInput) handleInputField8KeyDown(event input.KeyDownEvent) {
|
|
switch event.PropString("key") {
|
|
case "Enter":
|
|
c.AddToast(event.EventEnv(), &overlay.ToastSimple{
|
|
IconSlot: &icons.LInputField{AttrMap: vugu.AttrMap{"style": "font-size: 2em;"}},
|
|
Message: "You have entered: " + c.inputField8String,
|
|
SignalColor: "d3c-color-success",
|
|
Duration: 5 * time.Second,
|
|
})
|
|
event.PreventDefault()
|
|
}
|
|
}
|