Using Enter key in a screen without it progressing dialogue

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
User avatar
thirstyoctopus
Regular
Posts: 72
Joined: Mon Aug 27, 2018 12:04 pm
Projects: Romance Visual Novel story
Organization: Thirsty Octopus
Contact:

Using Enter key in a screen without it progressing dialogue

#1 Post by thirstyoctopus » Tue Jun 25, 2019 3:09 pm

Hi guys

I've implemented a cheat hud in my game for beta testing in order to add or remove crush points (which is a system I'm using to determine relationship progress) to a specific girl, and I have mapped the screen call to a specific key combo which works, however when the Enter key is pressed it activates the given cheat but also progresses dialogue, as if there were no screen showing.

Here is my screen code:

Code: Select all

screen cheat_hud():
    zorder 200

    window:
        xalign 0
        xfill False
        xpadding 0
        ypadding 0
        yalign 0
        background Image("gui/cheat_hud_bg.png", xalign=0, yalign=0)

        default cheat = ""
        vbox:
            text "Enter cheat here" size 13
            input:
                value ScreenVariableInputValue("cheat") size 12
            button:
                text "Submit" size 14
                action Call("process_cheat", cheat)
                keysym 'K_RETURN'
                alternate_keysym 'K_KP_ENTER'
As you see, I am allowing the Return or keypad Enter key to submit the cheat (as well as clicking the mouse on the text) but all of these actions will cause the story to progress, as normal. Basically what I want is a way to make sure that a press of the enter key or mouse click when this screen is called and visible does NOT do the default action of progressing story.

In order for the user to toggle the cheat hud itself, I use:

Code: Select all

screen cheat_toggle:
    if renpy.get_screen("cheat_hud"):
        key "alt_shift_K_SLASH" action Hide("cheat_hud")
    else:
        key "alt_shift_K_SLASH" action Show("cheat_hud")
Any help on this is appreciated as it can be awkward if a cheat is being entered but hitting enter moves the story on without the user knowing.

User avatar
Kia
Eileen-Class Veteran
Posts: 1011
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Using Enter key in a screen without it progressing dialogue

#2 Post by Kia » Mon Jul 08, 2019 10:09 am

try adding "modal True" to your screen, it prevents your input like clicks going through the screen.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]