mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-02-17 04:10:40 +01:00
insert the proper character at releasing a key after long pressing
This commit is contained in:
parent
b5a97813ca
commit
916a64774c
@ -1099,6 +1099,16 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
|
if (mMiniKeyboard != null) {
|
||||||
|
val coords = intArrayOf(0, 0)
|
||||||
|
mMiniKeyboard!!.getLocationOnScreen(coords)
|
||||||
|
val keys = mMiniKeyboard!!.mKeys
|
||||||
|
val widthPerKey = mMiniKeyboard!!.width / keys.size
|
||||||
|
var selectedKeyIndex = Math.floor((me.x - coords[0]) / widthPerKey.toDouble()).toInt()
|
||||||
|
selectedKeyIndex = Math.max(0, Math.min(selectedKeyIndex, keys.size - 1))
|
||||||
|
val selectedKeyCodes = keys[selectedKeyIndex].codes
|
||||||
|
onKeyboardActionListener!!.onKey(selectedKeyCodes[0], selectedKeyCodes.toIntArray())
|
||||||
|
}
|
||||||
dismissPopupKeyboard()
|
dismissPopupKeyboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2008 The Android Open Source Project
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item android:drawable="@drawable/btn_keyboard_key_pressed_on" android:state_checkable="true" android:state_checked="true" android:state_pressed="true" />
|
<item android:drawable="@drawable/btn_keyboard_key_pressed_on" android:state_checkable="true" android:state_checked="true" android:state_pressed="true" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user