Godot Version
4.6 4.6.2 4.7
Question
`extends Control
var ite:TextEdit
var ote:TextEdit
var btn:Button
#Below func works well on windows, but it failed when it was exported to android apk, no action
func on_press()->void:
ote.text=“haha”
func _ready() → void:
ite=get_node(“TextEdit”)
ote=get_node(“TextEdit2”)
btn=get_node(“Button”)
btn.pressed.connect(on_press)
func _process(delta: float) → void:
pass
Isn’t it presumptuous to assume you found a bug?
Isn’t it much more likely that you messed something up?
3 Likes
You’re not providing any information except the script, and it’s not properly formatted so not easy to even read
4 Likes
How did you configure touchscreen support in properties?
4 Likes
sorry, I can’t find the properties which is like the touchscreen or something else, can you give the more details? All other options in project are default.
What do your settings look like?
Ok, so what phone or tablet are you using? What version of android is it running?
honor play 7 t , android 12
It should work fine. You’re not on an old OS.
Again, your code is not formatted correctly, so I don’t know if it’s working, but if it does what you want with a mouse click, it should work on Android.
sorry, I can’t format the code properly on website, I modified the code below, but it still didn’t work.
Ok, I suggest you simplify your code. Add a button. Add this script to that button.
func _ready():
text = "Click me"
pressed.connect(_button_pressed)
func _button_pressed():
text = "Success!"
See if that button works. If it does, then it’s a problem with your code. If it doesn’t, it’s a problem with how the Android export is configured.
Also, are you using the Android editor?
You are right! I might find the reasons why press doesn’t work:
First, every time when you modified the code, you need to save it before exporting! (A stupid reason)
Second, you should not use godot-cpp-template project to develop the GDExtension; maybe it is too old for Godot. Instead, you can use the test demo of the godot-cpp project, which works very well.
Third, you can’t use the CMakeLists.txt file directly; you need to use Python SCons instead, or you will meet various errors.
Last, thank you for your help!
No problem. If that answer helped, please mark it as the solution for others coming after you.