forked from mbk-lab/rui_orig
2
0
Fork 0

Changed the type of KeyEvent.Code field

This commit is contained in:
anoshenko 2023-05-29 17:19:47 +03:00
parent c44093e6f4
commit d2204a8627
2 changed files with 6 additions and 5 deletions

View File

@ -153,7 +153,7 @@ type KeyEvent struct {
// Code holds a string that identifies the physical key being pressed. The value is not affected
// by the current keyboard layout or modifier state, so a particular key will always return the same value.
Code string
Code KeyCode
// Repeat == true if a key has been depressed long enough to trigger key repetition, otherwise false.
Repeat bool
@ -180,7 +180,8 @@ func (event *KeyEvent) init(data DataObject) {
}
event.Key, _ = data.PropertyValue("key")
event.Code, _ = data.PropertyValue("code")
code, _ := data.PropertyValue("code")
event.Code = KeyCode(code)
event.TimeStamp = getTimeStamp(data)
event.Repeat = getBool("repeat")
event.CtrlKey = getBool("ctrlKey")

View File

@ -622,8 +622,8 @@ func (popup *popupData) onDismiss() {
func (popup *popupData) keyEvent(event KeyEvent) bool {
if !event.AltKey && !event.CtrlKey && !event.ShiftKey && !event.MetaKey {
switch strings.ToLower(event.Code) {
case "enter":
switch event.Code {
case EnterKey:
for _, button := range popup.buttons {
if button.Type == DefaultButton && button.OnClick != nil {
button.OnClick(popup)
@ -631,7 +631,7 @@ func (popup *popupData) keyEvent(event KeyEvent) bool {
}
}
case "escape":
case EscapeKey:
if popup.cancelable {
popup.Dismiss()
return true