Fix backspace handling on Android.
This commit is contained in:
@@ -300,11 +300,16 @@ func HandleCursorMove(delta int) {
|
||||
// HandleKeyDown interprets keyboard events for navigation and editing.
|
||||
// Receives both key.Event (as key.Name) and key.EditEvent from the main loop.
|
||||
func HandleKeyDown(data any) {
|
||||
log.Printf("HandleKeyDown: received data of type %T: %v", data, data)
|
||||
switch v := data.(type) {
|
||||
case key.EditEvent:
|
||||
// Text input from IME / keyboard
|
||||
log.Printf("HandleKeyDown: EditEvent text=%q", v.Text)
|
||||
HandleInsert(v.Text)
|
||||
if v.Text == "\b" || len(v.Text) == 0 {
|
||||
HandleBackspace()
|
||||
} else {
|
||||
HandleInsert(v.Text)
|
||||
}
|
||||
case key.Name:
|
||||
log.Printf("HandleKeyDown: name=%q", v)
|
||||
switch v {
|
||||
@@ -553,6 +558,7 @@ func HandleInsert(s string) {
|
||||
|
||||
// HandleBackspace removes the character before the cursor.
|
||||
func HandleBackspace() {
|
||||
log.Printf("HandleBackspace: CursorPosition=%d", TheState.Editor.CursorPosition)
|
||||
pos := TheState.Editor.CursorPosition
|
||||
if pos == 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user