Page 1 of 1

Remove Blinking Text Cursor in Name Input?

Posted: Fri Jan 06, 2023 9:28 pm
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!

Re: Remove Blinking Text Cursor in Name Input?

Posted: Wed Jan 25, 2023 4:01 pm
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

Re: Remove Blinking Text Cursor in Name Input?

Posted: Wed Jan 25, 2023 8:41 pm
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.

Re: Remove Blinking Text Cursor in Name Input?

Posted: Thu Jan 26, 2023 2:56 am
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.

Re: Remove Blinking Text Cursor in Name Input?

Posted: Tue Nov 28, 2023 10:11 pm
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!