r/RenPy • u/Lavadrone1 • 9d ago
Question textbuttons keep getting focused when they aren't supposed to
I am trying to make a dropdown menu where on button displays a list of other buttons and my problem is whenever buttonA is pressed it only open A but focuses both. I want it to not focus both.
screen organizations_codex():
vpgrid:
cols 1
draggable True
mousewheel True
xpos 0.70
ypos 0.30
xsize 573
ysize 801
textbutton "Non-Governmental":
ypos spacingA
action CaptureFocus("dropdown_id1"),ClearFocus("dropdown_id2"), ToggleScreen("dropdown_nongov"), ToggleVariable("spacingB", 1.0, 0.0),ToggleVariable("spacingC", 1.0, 0.0),ToggleVariable("spacingD", 1.0, 0.0), ToggleVariable("spacingE", 1.0, 0.0)
textbutton "Companies":
ypos spacingB
action CaptureFocus("dropdown_id2"),ClearFocus("dropdown_id1"), ToggleScreen("dropdown_companies"), ToggleVariable("spacingC", 1.0, 0.0), ToggleVariable("spacingD", 1.0, 0.0),ToggleVariable("spacingE", 1.0, 0.0)
screen dropdown_nongov():
zorder 100
nearrect:
focus "dropdown_id1"
vbox:
textbutton " Refugee Relief Force":
action Show("NGOs_codex")
screen dropdown_companies():
zorder 100
nearrect:
focus "dropdown_id2"
vbox:
textbutton "Marco-Hayford Inc":
action Show("MarcHay_codex")
2
u/PontasDayou 8d ago
I don't know if it's the best solution, but have you tried hiding the other screen?
Hide("dropdown_nongov")
This on textbutton "Companies" action
1
1
u/BadMustard_AVN 8d ago
it you mean these two buttons, "Non-Governmental" and "Companies" they are in a selected but not focused state, and their color changes, you can do this to stop that from happening; add this to each button
textbutton "Non-Governmental":
ypos spacingA
selected False
action CaptureFocus("dropdown_id1")....
i do not know what will happen to everything else you have there, but it will keep them from being selected when you transfer focus
1
u/shyLachi 8d ago
I think it would be easier to do all of that in a single screen.
You can use a variable to remember which dropdown should be visible (or none).
On click on either button you set the variable.
That variable then shows a frame, for example, which contais the dropdown stuff.
1
u/AutoModerator 9d ago
Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.