Ren'Py Tutorial Enter Button on Android

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,772
Since I've seen this so many times in RenPy games threads, users asking for "Halp!!! Can't enter text/Input/Enter not working" and many dev's seem to ignore it or simply answer with "use the google keyboard" instead of fixing the problem, I thought I make this thread. I'm playing most the adult games on my android too, so I know it sux to change the keybord every time you have to input some text, and there are some games where you do it a lot. It's annoying...
The problem should actually not exist anymore with newer renpy versions (7.0.1+ I believe), but in fact, there are still many games where it still doesn't work, maybe because they are made before renpy V7.0.1 was out, or developement started with a earlier version. For these games a simple fix would be to include an enter button for text input on android. It's actually so easy I don't understand why so many dev's don't do it... maybe there are even easier solutions, I don't know, but this is how I did it:

In scripts.rpy somewhere at the top put this:
Python:
init -2 python:
    class GetInput(Action):
        def __init__(self,screen_name,input_id):
            self.screen_name=screen_name
            self.input_id=input_id
        def __call__(self):
            if renpy.get_widget(self.screen_name,self.input_id):
                return str(renpy.get_widget(self.screen_name,self.input_id).content)
and then in screens.rpy search for :
Python:
screen input(prompt):
    style_prefix "input"

    window:

        vbox:
            xalign gui.dialogue_text_xalign
            xpos gui.dialogue_xpos
            xsize gui.dialogue_width
            ypos gui.dialogue_ypos

            text prompt style "input_prompt"
            input id "input"
and replace it with:
Python:
screen input(prompt):
    style_prefix "input"

    window:

        vbox:
            xsize gui.dialogue_width
            if renpy.variant("touch"):
                xalign 0.6
                xpos 0.7
                ypos -600
                text prompt style "input_prompt":
                    color gui.choice_button_text_idle_color
                input id "input":
                    color gui.choice_button_text_idle_color
                textbutton "Ok" action GetInput("input","input"): #Ok is the text on the button, could also be "Enter", or "Go" or whatever you like
                    text_color gui.choice_button_text_idle_color
                    text_hover_color gui.choice_button_text_hover_color
            else:
                xalign gui.dialogue_text_xalign
                xpos gui.dialogue_xpos
                ypos gui.dialogue_ypos
                text prompt style "input_prompt"
                input id "input"
Done!
You now have a simple "OK" button in your input screen that shows only on android.
You don't have permission to view the spoiler content. Log in or register now.
The text and the button are styled like in menu choices and have the same hover effect.