mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
gg: fix .char event handling for backspace, delete, tab and enter for linux/x11 (send appropriate .char codes to the apps, similar to macos)
This commit is contained in:
parent
cab97894ae
commit
9387fe73e3
@ -468,6 +468,28 @@ fn gg_event_fn(ce voidptr, user_data voidptr) {
|
||||
// dump(e)
|
||||
}
|
||||
}
|
||||
$if linux {
|
||||
if e.typ == .key_down && e.key_code in [.backspace, .delete, .enter, .tab] {
|
||||
// with X11, sokol does not send .char events for some keys; we will emulate them for consistency here:
|
||||
e.char_code = match e.key_code {
|
||||
.backspace { u32(8) }
|
||||
.tab { 9 }
|
||||
.enter { 13 }
|
||||
.delete { 127 }
|
||||
else { u32(e.key_code) }
|
||||
}
|
||||
e.key_code = .invalid
|
||||
e.typ = .char
|
||||
if ctx.config.event_fn != unsafe { nil } {
|
||||
ctx.config.event_fn(e, ctx.config.user_data)
|
||||
} else if ctx.config.on_event != unsafe { nil } {
|
||||
ctx.config.on_event(ctx.config.user_data, e)
|
||||
}
|
||||
if ctx.config.char_fn != unsafe { nil } {
|
||||
ctx.config.char_fn(e.char_code, ctx.config.user_data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn gg_cleanup_fn(user_data voidptr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user