forked from mbk-lab/rui_orig
Changed the type of KeyEvent.Code field
This commit is contained in:
parent
c44093e6f4
commit
d2204a8627
|
@ -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")
|
||||
|
|
6
popup.go
6
popup.go
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue