insert the clipboard content on click
This commit is contained in:
parent
7c2d370459
commit
90d4215372
2 changed files with 15 additions and 1 deletions
|
@ -198,6 +198,10 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
|||
moveCursor(true)
|
||||
}
|
||||
|
||||
override fun onText(text: String) {
|
||||
currentInputConnection?.commitText(text, 0)
|
||||
}
|
||||
|
||||
private fun moveCursor(moveRight: Boolean) {
|
||||
val extractedText = currentInputConnection?.getExtractedText(ExtractedTextRequest(), 0) ?: return
|
||||
var newCursorPosition = extractedText.selectionStart
|
||||
|
|
|
@ -62,6 +62,12 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
* Called when the user long presses Space and moves to the right
|
||||
*/
|
||||
fun moveCursorRight()
|
||||
|
||||
/**
|
||||
* Sends a sequence of characters to the listener.
|
||||
* @param text the string to be displayed.
|
||||
*/
|
||||
fun onText(text: String)
|
||||
}
|
||||
|
||||
private var mKeyboard: MyKeyboard? = null
|
||||
|
@ -415,7 +421,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
background = rippleBg
|
||||
setTextColor(mTextColor)
|
||||
setOnClickListener {
|
||||
|
||||
mOnKeyboardActionListener!!.onText(clipboardContent.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -828,6 +834,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||
override fun moveCursorRight() {
|
||||
mOnKeyboardActionListener!!.moveCursorRight()
|
||||
}
|
||||
|
||||
override fun onText(text: String) {
|
||||
mOnKeyboardActionListener!!.onText(text)
|
||||
}
|
||||
}
|
||||
|
||||
val keyboard = if (popupKey.popupCharacters != null) {
|
||||
|
|
Loading…
Reference in a new issue