Fix backspace handling on Android.
This commit is contained in:
parent
5a92ee9df3
commit
b224bbe85a
|
|
@ -120,11 +120,16 @@ func run(w *app.Window) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
case key.EditEvent:
|
case key.EditEvent:
|
||||||
log.Printf("edit event: %v", k.Text)
|
log.Printf("edit event text: %q", k.Text)
|
||||||
events = append(events, ui.InputEvent{
|
events = append(events, ui.InputEvent{
|
||||||
Handler: reg.Handler,
|
Handler: reg.Handler,
|
||||||
Data: k,
|
Data: k,
|
||||||
})
|
})
|
||||||
|
case key.SnippetEvent:
|
||||||
|
log.Printf("snippet event: %v", k)
|
||||||
|
// Handle snippet event if necessary, or ignore
|
||||||
|
default:
|
||||||
|
log.Printf("unexpected event type: %T", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -300,11 +300,16 @@ func HandleCursorMove(delta int) {
|
||||||
// HandleKeyDown interprets keyboard events for navigation and editing.
|
// HandleKeyDown interprets keyboard events for navigation and editing.
|
||||||
// Receives both key.Event (as key.Name) and key.EditEvent from the main loop.
|
// Receives both key.Event (as key.Name) and key.EditEvent from the main loop.
|
||||||
func HandleKeyDown(data any) {
|
func HandleKeyDown(data any) {
|
||||||
|
log.Printf("HandleKeyDown: received data of type %T: %v", data, data)
|
||||||
switch v := data.(type) {
|
switch v := data.(type) {
|
||||||
case key.EditEvent:
|
case key.EditEvent:
|
||||||
// Text input from IME / keyboard
|
// Text input from IME / keyboard
|
||||||
log.Printf("HandleKeyDown: EditEvent text=%q", v.Text)
|
log.Printf("HandleKeyDown: EditEvent text=%q", v.Text)
|
||||||
|
if v.Text == "\b" || len(v.Text) == 0 {
|
||||||
|
HandleBackspace()
|
||||||
|
} else {
|
||||||
HandleInsert(v.Text)
|
HandleInsert(v.Text)
|
||||||
|
}
|
||||||
case key.Name:
|
case key.Name:
|
||||||
log.Printf("HandleKeyDown: name=%q", v)
|
log.Printf("HandleKeyDown: name=%q", v)
|
||||||
switch v {
|
switch v {
|
||||||
|
|
@ -553,6 +558,7 @@ func HandleInsert(s string) {
|
||||||
|
|
||||||
// HandleBackspace removes the character before the cursor.
|
// HandleBackspace removes the character before the cursor.
|
||||||
func HandleBackspace() {
|
func HandleBackspace() {
|
||||||
|
log.Printf("HandleBackspace: CursorPosition=%d", TheState.Editor.CursorPosition)
|
||||||
pos := TheState.Editor.CursorPosition
|
pos := TheState.Editor.CursorPosition
|
||||||
if pos == 0 {
|
if pos == 0 {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user