2021-09-09 12:08:31 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/anoshenko/rui"
|
|
|
|
)
|
|
|
|
|
|
|
|
func keyEventHandle(view rui.View, event rui.KeyEvent, tag string) {
|
|
|
|
var buffer strings.Builder
|
|
|
|
|
|
|
|
buffer.WriteString(tag)
|
|
|
|
buffer.WriteString(`: TimeStamp = `)
|
|
|
|
buffer.WriteString(strconv.FormatUint(event.TimeStamp, 10))
|
|
|
|
buffer.WriteString(`, Key = "`)
|
|
|
|
buffer.WriteString(event.Key)
|
|
|
|
buffer.WriteString(`", Code = "`)
|
|
|
|
buffer.WriteString(event.Code)
|
|
|
|
buffer.WriteString(`"`)
|
|
|
|
|
|
|
|
appendBool := func(name string, value bool) {
|
|
|
|
buffer.WriteString(`, `)
|
|
|
|
buffer.WriteString(name)
|
|
|
|
if value {
|
|
|
|
buffer.WriteString(` = true`)
|
|
|
|
} else {
|
|
|
|
buffer.WriteString(` = false`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
appendBool("Repeat", event.Repeat)
|
|
|
|
appendBool("CtrlKey", event.CtrlKey)
|
|
|
|
appendBool("ShiftKey", event.ShiftKey)
|
|
|
|
appendBool("AltKey", event.AltKey)
|
|
|
|
appendBool("MetaKey", event.MetaKey)
|
|
|
|
buffer.WriteString(";\n\n")
|
|
|
|
|
|
|
|
rui.AppendEditText(view, "", buffer.String())
|
|
|
|
rui.ScrollViewToEnd(view, "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func createKeyEventsDemo(session rui.Session) rui.View {
|
|
|
|
return rui.NewEditView(session, rui.Params{
|
|
|
|
rui.Width: rui.Percent(100),
|
|
|
|
rui.Height: rui.Percent(100),
|
|
|
|
rui.ReadOnly: true,
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
rui.EditWrap: true,
|
2021-09-09 12:08:31 +03:00
|
|
|
rui.Hint: "Set the focus and press a key",
|
|
|
|
rui.EditViewType: rui.MultiLineText,
|
|
|
|
rui.KeyDownEvent: func(view rui.View, event rui.KeyEvent) {
|
|
|
|
keyEventHandle(view, event, rui.KeyDownEvent)
|
|
|
|
},
|
|
|
|
rui.KeyUpEvent: func(view rui.View, event rui.KeyEvent) {
|
|
|
|
keyEventHandle(view, event, rui.KeyUpEvent)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|