mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
io/key: implement key.Release state
Implement key state for the following platforms: js, wayland, windows, x11. Unsupported platforms will continue to function as before, sending key.Press for all key events. Signed-off-by: Josiah Niedrauer <josiah@niedrauer.com>
This commit is contained in:
committed by
Elias Naur
parent
ef652f4922
commit
42e568775c
@@ -150,7 +150,7 @@ func (x *Context) Modifiers() key.Modifiers {
|
||||
return mods
|
||||
}
|
||||
|
||||
func (x *Context) DispatchKey(keyCode uint32) (events []event.Event) {
|
||||
func (x *Context) DispatchKey(keyCode uint32, state key.State) (events []event.Event) {
|
||||
if x.state == nil {
|
||||
return
|
||||
}
|
||||
@@ -163,6 +163,7 @@ func (x *Context) DispatchKey(keyCode uint32) (events []event.Event) {
|
||||
cmd := key.Event{
|
||||
Name: name,
|
||||
Modifiers: x.Modifiers(),
|
||||
State: state,
|
||||
}
|
||||
// Ensure that a physical backtab key is translated to
|
||||
// Shift-Tab.
|
||||
@@ -201,7 +202,7 @@ func (x *Context) DispatchKey(keyCode uint32) (events []event.Event) {
|
||||
str = str[:len(str)-s]
|
||||
}
|
||||
}
|
||||
if len(str) > 0 {
|
||||
if state == key.Press && len(str) > 0 {
|
||||
events = append(events, key.EditEvent{Text: string(str)})
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user