some text input changes

This commit is contained in:
Chloe committed 2025-06-07 19:38:01 -07:00
1 parent 09bb28d66f
commit c77271f45c
4 files changed
+16 -32

No files matched your search

@@ -1,18 +0,0 @@
package org.cocos2dx.lib
import android.content.Context
import android.view.KeyEvent
import androidx.appcompat.widget.AppCompatEditText
class Cocos2dxEditText(context: Context) : AppCompatEditText(context) {
var cocos2dxGLSurfaceView: Cocos2dxGLSurfaceView? = null
override fun onKeyDown(keyCode: Int, keyEvent: KeyEvent): Boolean {
super.onKeyDown(keyCode, keyEvent)
if (keyCode != KeyEvent.KEYCODE_BACK) {
return true
}
cocos2dxGLSurfaceView?.requestFocus()
return true
}
}
@@ -13,6 +13,7 @@ import android.view.MotionEvent
import android.view.Surface
import android.view.inputmethod.InputMethodManager
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.AppCompatEditText
import com.customRobTop.BaseRobTopActivity
import com.geode.launcher.utils.GeodeUtils
@@ -57,12 +58,11 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
var sendTimestampEvents = false
var manualBackEvents = false
var cocos2dxEditText: Cocos2dxEditText? = null
var cocos2dxEditText: AppCompatEditText? = null
set(value) {
field = value
field?.setOnEditorActionListener(cocos2dxTextInputWrapper)
field?.cocos2dxGLSurfaceView = this
requestFocus()
}
@@ -261,6 +261,10 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
}
fun sendKeyBack() {
if (cocos2dxEditText?.isFocused == true) {
requestFocus()
}
if (BaseRobTopActivity.blockBackButton) {
return
}
@@ -52,12 +52,10 @@ class Cocos2dxTextInputWrapper(private val cocos2dxGLSurfaceView: Cocos2dxGLSurf
cocos2dxGLSurfaceView.deleteBackward()
}
var text = textView.text.toString()
if (text.compareTo("") == 0) {
text = "\n"
}
if (10 != text[text.length - 1].code) {
text += 10.toChar()
if (!text.endsWith('\n')) {
text += '\n'
}
cocos2dxGLSurfaceView.insertText(text)
}
if (actionID != 6) {