Dropdown menu code?

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
eath
Newbie
Posts: 10
Joined: Tue Jul 14, 2020 11:52 am
Contact:

Dropdown menu code?

#1 Post by eath » Tue Jul 21, 2020 9:46 am

Has anyone written a collapsible dropdown menu system you wouldn't mind sharing? For example: Edit > Text > Font > Size > 12

I've only found two snippets of possible dropdown code and they're not working correctly (even after messing with them).
viewtopic.php?t=26883
viewtopic.php?t=48981

From all the threads I've read in my search, it seems like this would be useful to a lot of people!

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Dropdown menu code?

#2 Post by Per K Grok » Tue Jul 21, 2020 12:56 pm

eath wrote:
Tue Jul 21, 2020 9:46 am
Has anyone written a collapsible dropdown menu system you wouldn't mind sharing? For example: Edit > Text > Font > Size > 12

I've only found two snippets of possible dropdown code and they're not working correctly (even after messing with them).
viewtopic.php?t=26883
viewtopic.php?t=48981

From all the threads I've read in my search, it seems like this would be useful to a lot of people!

You can make a simple dropdown menu like this.

Code: Select all

default closed=True

screen drop():
    vbox:
        frame:
            if closed:
                textbutton "Menu" action SetVariable("closed", False)
            elif closed==False:
                textbutton "Menu" action SetVariable("closed", True)
        if closed==False:
            frame:
                vbox:
                    text "text1"
                    text "text2"
                    text "text3"
                    text "text4"
                    text "text5"

eath
Newbie
Posts: 10
Joined: Tue Jul 14, 2020 11:52 am
Contact:

Re: Dropdown menu code?

#3 Post by eath » Tue Jul 21, 2020 3:42 pm

Per K Grok wrote:
Tue Jul 21, 2020 12:56 pm

You can make a simple dropdown menu like this.

Code: Select all

default closed=True

screen drop():
    vbox:
        frame:
            if closed:
                textbutton "Menu" action SetVariable("closed", False)
            elif closed==False:
                textbutton "Menu" action SetVariable("closed", True)
        if closed==False:
            frame:
                vbox:
                    text "text1"
                    text "text2"
                    text "text3"
                    text "text4"
                    text "text5"

Thank you Per K Grok! I'm going to see if I can dynamically populate the buttons using an ordereddict and post it here.

One question: if there's another menu a few pixels south of this, is there a way to "push" it down further temporarily while this menu is open?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Dropdown menu code?

#4 Post by Per K Grok » Sat Jul 25, 2020 12:28 pm

eath wrote:
Tue Jul 21, 2020 3:42 pm

----

Thank you Per K Grok! I'm going to see if I can dynamically populate the buttons using an ordereddict and post it here.

One question: if there's another menu a few pixels south of this, is there a way to "push" it down further temporarily while this menu is open?
If you add a frame below the dropdown frame like this. The lower frame will move along with the dropdown frame.

Code: Select all

screen drop():
    vbox:
        frame:
            if closed:
                textbutton "Menu" action SetVariable("closed", False)
            elif closed==False:
                textbutton "Menu" action SetVariable("closed", True)
        if closed==False:
            frame:
                vbox:
                    text "text1"
                    text "text2"
                    text "text3"
                    text "text4"
                    text "text5"
        frame:
            vbox:
                text "textA"
                text "textS"
                text "textD"
                text "textF"
                text "textG"


Post Reply

Who is online

Users browsing this forum: Bing [Bot], span4ev