Remove Blinking Text Cursor in Name Input?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Hojoo
Newbie
Posts: 20
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

Remove Blinking Text Cursor in Name Input?

#1 Post by Hojoo »

The input for my character's name is through a textbox on the character creator screen (instead of opening up a new dialogue), but right now the blinking text cursor in the name box persists even after nothing's being inputted. Is there a way to have the cursor stop blinking once input is done, or to remove the cursor altogether?

These are the functions I'm using to take a value and store it as names:

Code: Select all

init python:
    def forname_func(newstring):
        store.forname = newstring
    def surname_func(newstring):
        store.surname = newstring
And these are buttons under an imagemap, which show a default name on screen that can be replaced with a new name on hover:

Code: Select all

        button:
            id "forname_input"
            pos (63,12)
            action NullAction()
            add Input(size=8, length=13, hover_color="#ffffff", color="#e2d4bf", default=forname, changed=forname_func, button=renpy.get_widget("nameinput","forname_input"))
        button:
            id "surname_input"
            pos (67,20)
            action NullAction()
            add Input(size=8, length=10, hover_color="#ffffff", color="#e2d4bf", default=surname, changed=surname_func, button=renpy.get_widget("nameinput","surname_input"))
If this is something that can be done, or if there's a different way to do this, please let me know! Thank you!

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1118
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Remove Blinking Text Cursor in Name Input?

#2 Post by m_from_space »

Here is what I came up with. Hovering the area will let you edit it (so the cursor appears). Unhovering will disable the input, so the cursor disappears. [The user can also click on it to enable or disable it. You may use NullAction() here if you want.]

Code: Select all

default char_name = "My Character"

screen input_screen:
    modal True
    default input_object = VariableInputValue("char_name", default=False)
    vbox:
        button:
            action input_object.Toggle()
            hovered input_object.Enable()
            unhovered input_object.Disable()
            key_events True
            input:
                length 13
                value input_object
        textbutton "Done" action Return()

label start:

    call screen input_screen

    "Your name: [char_name]."

    return

enaielei
Veteran
Posts: 293
Joined: Fri Sep 17, 2021 2:09 am
Organization: enaielei
Tumblr: enaielei
Deviantart: enaielei
Github: enaielei
Skype: enaielei
Soundcloud: enaielei
itch: enaielei
Discord: enaielei#7487
Contact:

Re: Remove Blinking Text Cursor in Name Input?

#3 Post by enaielei »

See that there's a caret_blink property for inputs which you can manipulate.
Correct me if I'm wrong but I think this property is also new, so it's prolly only available on the latest version of Ren'Py.

User avatar
m_from_space
Eileen-Class Veteran
Posts: 1118
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Remove Blinking Text Cursor in Name Input?

#4 Post by m_from_space »

enaielei wrote: Wed Jan 25, 2023 8:41 pm See that there's a caret_blink property for inputs which you can manipulate.
Correct me if I'm wrong but I think this property is also new, so it's prolly only available on the latest version of Ren'Py.
Setting it to "False" will still show the caret though (not blinking), which makes sense. You want the user to realize where the focus is. Hitting "Return" in my example will also disable the input and therefore hide the caret.

Hojoo
Newbie
Posts: 20
Joined: Wed Sep 28, 2022 7:26 pm
Contact:

Re: Remove Blinking Text Cursor in Name Input?

#5 Post by Hojoo »

Thanks everybody! I figured out even another workaround to remove the blinking cursor using the caret and idle_caret properties.

The functions to take a value and store it as names can stay the same:

Code: Select all

init python:
    def forname_func(newstring):
        store.forname = newstring
    def surname_func(newstring):
        store.surname = newstring
But if the buttons under the imagemap include caret="images/blank.png", which is just a blank 1×1 image, then the whole caret goes invisible, which is nice. I personally also included idle_caret=None, which means that it still blinks when you hover over it (there's also minor formatting changes in this version, purely aesthetic).

Code: Select all

        button id "forname_input" pos (63,12):
            add Input(default=forname, size=8, length=13, hover_color="#ffffff", color="#e2d4bf", font='gui/alkhemikal.ttf', caret="images/blank.png", idle_caret=None, changed=forname_func, button=renpy.get_widget("nameinput","forname_input"))
            action NullAction()
        button id "surname_input" pos (67,20):
            add Input(default=surname, size=8, length=10, hover_color="#ffffff", color="#e2d4bf", font='gui/alkhemikal.ttf', caret="images/blank.png", idle_caret=None, changed=surname_func, button=renpy.get_widget("nameinput","surname_input"))
            action NullAction()
Hope this helps someone!

Post Reply

Who is online

Users browsing this forum: No registered users