mirror of
https://github.com/dessalines/thumb-key.git
synced 2025-01-08 15:07:01 +03:00
Make the backspace key remove text directly instead of sending a DEL keycode (#1162)
This commit is contained in:
parent
ac514dad22
commit
9c08defdef
@ -144,14 +144,7 @@ val BACKSPACE_KEY_ITEM =
|
||||
center =
|
||||
KeyC(
|
||||
display = KeyDisplay.IconDisplay(Icons.AutoMirrored.Outlined.KeyboardBackspace),
|
||||
action =
|
||||
SendEvent(
|
||||
KeyEvent(
|
||||
KeyEvent.ACTION_DOWN,
|
||||
KeyEvent
|
||||
.KEYCODE_DEL,
|
||||
),
|
||||
),
|
||||
action = DeleteKeyAction,
|
||||
size = LARGE,
|
||||
color = SECONDARY,
|
||||
),
|
||||
|
@ -164,6 +164,8 @@ sealed class KeyAction {
|
||||
data object CycleRight : KeyAction()
|
||||
}
|
||||
|
||||
data object DeleteKeyAction : KeyAction()
|
||||
|
||||
data object DeleteWordBeforeCursor : KeyAction()
|
||||
|
||||
data object DeleteWordAfterCursor : KeyAction()
|
||||
|
@ -361,6 +361,14 @@ fun performKeyAction(
|
||||
ime.currentInputConnection.sendKeyEvent(ev)
|
||||
}
|
||||
|
||||
is KeyAction.DeleteKeyAction -> {
|
||||
if (ime.currentInputConnection.getSelectedText(0)?.isEmpty() != false) {
|
||||
ime.currentInputConnection.deleteSurroundingText(1, 0)
|
||||
} else {
|
||||
ime.currentInputConnection.commitText("", 0)
|
||||
}
|
||||
}
|
||||
|
||||
is KeyAction.DeleteWordBeforeCursor -> {
|
||||
Log.d(TAG, "deleting last word")
|
||||
deleteWordBeforeCursor(ime)
|
||||
|
Loading…
Reference in New Issue
Block a user