Manually trig "hide" event when closing menu with Return()

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
nekoman
Newbie
Posts: 22
Joined: Sun Aug 17, 2014 2:21 pm
Location: Italy
Contact:

Manually trig "hide" event when closing menu with Return()

#1 Post by nekoman »

Hello everyone,

I'm new to Renpy, forgive me if this topic already have an answer somewhere (I didn't find it though).

I'm building a right click menu, using the "screen language". One of the widgets should have a transform that changes its behavior depending on if the menu it's opening or closing.
Well, using the "on" statement, since the "show" event is called, everything goes fine. The problem is that the action Return() doesn't trigger the "hide" event. I think is because the menu is called on a new context.

Anyway, there is a way to trigger manually the "hide" event when closing a screen with Return(), or maybe there is some trick to solve this problem?
Last edited by nekoman on Tue Aug 19, 2014 3:56 am, edited 1 time in total.

User avatar
dyrarendy
Regular
Posts: 59
Joined: Wed Apr 02, 2014 12:26 pm
Projects: Visual Novel Dating Sims Masa SMA
Location: Indonesia, Cimahi
Contact:

Re: Manually trig "onhide" event when closing menu with Retu

#2 Post by dyrarendy »

Can i see your Script that contains Return() and "hide" event ?
My Project :
Image

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Manually trig "onhide" event when closing menu with Retu

#3 Post by xela »

There is a weird bug there even without using Return. I doubt he's doing anything wrong. There are plenty workarounds (I just don't know which one to suggest without seeing the code) and maybe PyTom can fix it in 6.18.
Like what we're doing? Support us at:
Image

User avatar
nekoman
Newbie
Posts: 22
Joined: Sun Aug 17, 2014 2:21 pm
Location: Italy
Contact:

Re: Manually trig "onhide" event when closing menu with Retu

#4 Post by nekoman »

dyrarendy wrote:Can i see your Script that contains Return() and "hide" event ?
The actual screen script is a bit long. I'll type an equivalent.

Code: Select all


# Need some setup to work
init python:
    # setup transitions
    config.enter_transition = Dissolve(0.3)
    config.exit_transition = Dissolve(0.3)

    # set game menu entry screen
    _game_menu_screen = "myscreen"

#-----------------------------------------------

# A transform for the button
transform mytransform:
    align (0.5, 0.5)
    on show:
        xoffset 300 alpha .0
        easein .2 xoffset 0 alpha 1.0

    # this doesn't trig with Return()
    on hide:
        easein .2 xoffset 300 alpha .0


#-----------------------------------------------

screen myscreen:
    tag menu

    vbox at mytransform:
        textbutton "Close" action Return()

This is an expected behavior since in manual says explicitly that Return() doesn't trig the hide event.
I think this is a big limitation.

Anyway I wanted to know if there is a manual way to trig the event.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Manually trig "hide" event when closing menu with Return

#5 Post by xela »

I thought you meant something competely different...

Did you try:

Code: Select all

textbutton "Close" [Hide("myscreen"), action Return()]
by any chance?
Like what we're doing? Support us at:
Image

User avatar
nekoman
Newbie
Posts: 22
Joined: Sun Aug 17, 2014 2:21 pm
Location: Italy
Contact:

Re: Manually trig "hide" event when closing menu with Return

#6 Post by nekoman »

xela wrote:I thought you meant something competely different...

Did you try:

Code: Select all

textbutton "Close" [Hide("myscreen"), action Return()]
by any chance?
Yes, it doesn't work.
Also I trying switching using variables but since the two calls belongs to different context, I couldn't get it work.

P.S.

I actually tried:

Code: Select all

textbutton "Close" action [Hide("myscreen"), Return()]

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Manually trig "hide" event when closing menu with Return

#7 Post by nyaatrap »

When you call a screen using renpy.calls_in_new_context, transforms don't work when you close it with return. I think transforms are killed while executing return operation even it starts working. (When it called by renpy.call_screen, then it works correctly)

Post Reply

Who is online

Users browsing this forum: Adabelitoo