Renpy On Screen / Touch Screen Keyboard. PC / Android.

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
dyrarendy
Regular
Posts: 59
Joined: Wed Apr 02, 2014 12:26 pm
Projects: Visual Novel Dating Sims Masa SMA
Location: Indonesia, Cimahi
Contact:

Renpy On Screen / Touch Screen Keyboard. PC / Android.

#1 Post by dyrarendy »

Well, i had done to configure the keyboard.

Its Based on :

-Array
-Frame
-Button
-Keyboard Image
---------------------------------------------------------------------------------------------------------------------------
I'm Edit the code and the Picture.
This is "Keyboard On-Screen solution" for anyone use 1280 x 720 resolution :

Code: Select all

########################################################

init python:
    text_list1=["Q","W","E","R","T","Y","U","I","O","P","0",
                      "A","S","D","F","G","H","J","K","L","0",
                      "Z","X","C","V","B","N","M","0"]
    text_list2=["q","w","e","r","t","y","u","i","o","p","0",
                      "a","s","d","f","g","h","j","k","l","0",
                      "z","x","c","v","b","n","m","0"]
    input_text = ''
    input_header = 'NAME:'
    text_limit = 16
    text_list=text_list1
    text_group=1
########################################################
    
label inputter:
    if text_group==1:
        $text_list=text_list1
    elif text_group==2:
        $text_list=text_list2
         
    $ ui.frame(xalign=0.5, yalign=0.5)
    $ ui.vbox()
    $ ui.text(input_header+" "+input_text)
    $ ui.null(height=50)

    $ ui.hbox(xalign=0.5, yalign=1.0)
    $ ui.textbutton("{size=+10}Done{/size}", clicked=ui.returns("Done"))
    $ui.textbutton("{size=+10}Backspace{/size}", clicked=ui.returns("Backspace"))
    $ui.textbutton("{size=+10}Clear{/size}", clicked=ui.returns("Deleteall"))
    if text_group==1:
        $ ui.textbutton("{size=+10}Caps (On){/size}", clicked=ui.returns("lowercase"))
        image keyboard = "keyboard.png"
        hide keyboard2
        show keyboard
    elif text_group==2:
        $ ui.textbutton("{size=+10}Caps (Off){/size}", clicked=ui.returns("uppercase"))
        image keyboard2 = "keyboard2.png"
        hide keyboard
        show keyboard2
    $ ui.close()

    $ ui.null(height=25)

    $ ui.hbox(xalign= 0.5)

    python:
        for text_code in text_list:
            if text_code=="0":
                ui.close()
                ui.hbox(xalign= 0.5)
            elif  len(input_text)<=text_limit-1:
                ui.textbutton('{size=+47}   {/size}', clicked=ui.returns(text_code))
    $ ui.close()
    $ ui.close()
    $ button_selection=ui.interact()
               
    if button_selection=="Backspace":
        $ input_text=input_text[:-1]
        jump inputter
    elif button_selection=="Deleteall":
        $ input_text=''
        jump inputter
    elif button_selection=="uppercase":
        $text_group=1
        jump inputter
    elif button_selection=="lowercase":
        $text_group=2
        jump inputter
    elif button_selection=="Done":
        hide keyboard
        hide keyboard2
        return
    $ select_text=button_selection

    python:
        for text_code in text_list:
            if select_text==text_code:
                input_text += text_code
    jump inputter
---------------------------------------------------------------------------------------------------------------------------
Warning : Do not modify the "SPACE" at line below this.
( You "Must Edit" (This Code, or Keyboard Image) if your Game resolution are below or under 1280 x 720 px. )
Or everything will be not same. The "KEY" of keyboard width and height that match the keyboard image, are here :

Code: Select all

ui.textbutton('{size=+47}   {/size}', clicked=ui.returns(text_code))

The "KEY" to show up Uppercase or lowercase Letter are :

Code: Select all

  if text_group==1:
        $ ui.textbutton("{size=+10}Caps (On){/size}", clicked=ui.returns("lowercase"))
        image keyboard = "keyboard.png"
        hide keyboard2
        show keyboard
    elif text_group==2:
        $ ui.textbutton("{size=+10}Caps (Off){/size}", clicked=ui.returns("uppercase"))
        image keyboard2 = "keyboard2.png"
        hide keyboard
        show keyboard2
This is the caracter input code :

Code: Select all

label character :

        "What is your first name? (leave blank for 'Name')"
        $ input_header = 'Input First name:'
        call inputter
        $ povFirstName = input_text or "Name"
        "What is your last name? (leave blank for 'Surname')"
        $ input_header = 'Input Last name:'
        $ text_group = 1
        $ input_text = ''
        call inputter
        $ povLastName = input_text or "Surname"
        $ povName = povFirstName +" "+povLastName

And this is action to hide the keyboard :

Code: Select all

    elif button_selection=="Done":
        hide keyboard
        hide keyboard2
        return
Anyway, i think with this solution. We HAVE ON-SCREEN KEYBOARD now. Thats works Well for ANDROID or another Touchscreen Devices.
---------------------------------------------------------------------------------------------------------------------------
This On-Screen Keyboard are modified by me, and thanks to :

http://lemmasoft.renai.us/forums/viewto ... =8&t=14985
http://lemmasoft.renai.us/forums/member ... le&u=19404
Attachments
Screen Shots with :<br />&quot;qwertyuiop&quot;
Screen Shots with :
"qwertyuiop"
Screen Shots with :<br />&quot;QWERTYUIOP&quot;
Screen Shots with :
"QWERTYUIOP"
The Keyboard :<br />&quot;qwertyuiop&quot;
The Keyboard :
"qwertyuiop"
The Keyboard :<br />&quot;QWERTYUIOP&quot;
The Keyboard :
"QWERTYUIOP"
Last edited by dyrarendy on Thu Apr 03, 2014 2:37 am, edited 2 times in total.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: Renpy On Screen Keyboard / Touch Screen Keyboard. Androi

#2 Post by noeinan »

Oh, WOW! This is super cool! :D I've primarily wanted to release my games on Android/Ouya so thank you very much for sharing this!
Image

Image
Image

User avatar
dyrarendy
Regular
Posts: 59
Joined: Wed Apr 02, 2014 12:26 pm
Projects: Visual Novel Dating Sims Masa SMA
Location: Indonesia, Cimahi
Contact:

Re: Renpy On Screen / Touch Screen Keyboard. PC / Android.

#3 Post by dyrarendy »

Welcome.

But I think its really "Possible" to create The New Keyboard from GUI "Imagebutton".
The Keyboard will really Fancier.

But, i didn't good at creating "images.png" for it.
My Project :
Image

Post Reply

Who is online

Users browsing this forum: No registered users