Skip to content

Commit

Permalink
fix: temporary workaround for duplicated return action (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiredPlanck committed Nov 11, 2024
1 parent b5fbc33 commit ff524bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
is RimeEvent.KeyEvent ->
it.data.let event@{
val keyCode = it.value.keyCode
// TODO: look for better workaround for this
if (it.modifiers == KeyModifiers.Empty) {
when (keyCode) {
KeyEvent.KEYCODE_ENTER -> handleReturnKey()
else -> commitText(Char(it.unicode).toString())
}
return@event
}
if (keyCode != KeyEvent.KEYCODE_UNKNOWN) {
val eventTime = SystemClock.uptimeMillis()
if (it.up) {
Expand Down Expand Up @@ -318,7 +326,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
instance = null
}

fun handleReturnKey() {
private fun handleReturnKey() {
currentInputEditorInfo.run {
if (inputType and InputType.TYPE_MASK_CLASS == InputType.TYPE_NULL) {
sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ class CommonKeyboardActionListener(
shouldReleaseKey = false

when (keyEventCode) {
KeyEvent.KEYCODE_ENTER -> service.handleReturnKey()
KeyEvent.KEYCODE_BACK, KeyEvent.KEYCODE_ESCAPE -> service.requestHideSelf(0)
KeyEvent.KEYCODE_BACK -> service.requestHideSelf(0)
else -> {
// 小键盘自动增加锁定
if (keyEventCode in KeyEvent.KEYCODE_NUMPAD_0..KeyEvent.KEYCODE_NUMPAD_EQUALS) {
Expand Down

0 comments on commit ff524bc

Please sign in to comment.