[solved!]Do we need action NullAction() when using hovered and unhovered??

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
stonecold997
Newbie
Posts: 6
Joined: Sun Jul 29, 2018 9:22 am
Contact:

[solved!]Do we need action NullAction() when using hovered and unhovered??

#1 Post by stonecold997 »

캡처.JPG
Hi! LemmaSoft Users! I am currently studying ren'py's GUI and I can't seem to figure out how to make my screen disappear when unhovered.

yes, I'm aware that in Renpy's Screen Action document, and in Screen document,
it does say that we can make button's area to run actions, such as [action, hovered, unhovered, etc...] and we can make Screen Actions when button's actions are invoked.

So what I want to do is, when I unhover the button, the screen should disappear. Thought this would be easier when I use unhovered... but I got stuck here
캡처.JPG
there are 2 screens above, the home menu screen involving 4 options(get out, computer, sleep, inventory), and the main schedule screen involving 2 options (training room, library.)

When I toggle, or hover the 4 optioned screen, the 2 optioned screen should appear. __ I could easily progress by using hovered or action ToggleScreen.

Now, 2 optioned screen has appeared and I want to make the screen disappear when the mouse unhovers the 2 optioned screen area.

The first method I've thought is
when I use unhovered in each 2 textbuttons(training room, library) and Hide the 2 optioned screen, it hides the 2 optioned screen when each buttons are unhovered, but with this method, I can't move my mouse freely in 2 optioned screen because even when it unhovers one of the button, the 2 optioned screen disappears. I want my 2 optioned screen appear untill the mouse unhovers the 2 optioned screen's area.

so I tried another method with buttons and vbox

Code: Select all

    screen homeMain:
        frame:
            align(0.25,0.3)
            button:
                vbox:
                    textbutton "go out":
                        action ToggleScreen("homeSchedule")
                    textbutton "computer":
                        action NullAction()
                    textbutton "inventory":
                        action NullAction()
                    textbutton "sleep":
                        action Return(True)

    screen homeSchedule():
            frame:
                align(0.35,0.3)
                button:
                	unhovered Hide("homeSchedule")
                   	 vbox:
                    	   	 textbutton "training room":
                      	 	     action NullAction()
                     		   textbutton "library":
                      	 	     action NullAction()
                    
I thought this method would work, but it doesn't.... and I can't find a reason why. Should there be a NullAction such as below?
[code][file][/file]
  button:
  			action NullAction()
                	unhovered Hide("homeSchedule")
                   	 vbox:
                    	   	 textbutton "training room":
                      	 	     action NullAction()
                     		   textbutton "library":
                      	 	     action NullAction()
and why?

the third method I tried to use is make a variable ("menuHover") using bool/flag and when an hover/unhover occurs, I set the variable to True/Fasle. Then , When the variable is fasle, it hides the screen. But... It doens't seem to work either, and other probelm with this is that every time I have to use this GUI, I have to make other flags, and it takes more effort to make it oraganized.

so... That's all I've tried and nothing worked.
maybe there's more methods but I can't think of it now... maybe I'm a newbie to programming.. So I came here, to forum to question about it cuz there are a lot of experienced coders in this forum...


sorry for bad English... I really tried to make it understandable
Last edited by stonecold997 on Sun Aug 26, 2018 11:47 am, edited 3 times in total.

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: I want to make my screen disappear when mouse unhovers the 'area'

#2 Post by MaydohMaydoh »

Button needs an action for hovered and unhovered to work, so action NullAction() should be give to those buttons.
When you hover over a new button, even if that button is inside the button, the main button will lose focus, unhovering it. So when you hover over one of the textbuttons the main button loses focus and the unhovered action runs.
Basically, your second method would get what you want. Just give each textbutton a hovered action to re-show the screen.

Code: Select all

screen homeSchedule():
    frame:
       align (0.35, 0.3)
       button action NullAction() unhovered Hide('homeSchedule'):
           
           vbox:
               textbutton "Training Room" action NullAction() hovered Show('homeSchedule')
               textbutton "Library" action NullAction() hovered Show('homeSchedule')

stonecold997
Newbie
Posts: 6
Joined: Sun Jul 29, 2018 9:22 am
Contact:

Re: I want to make my screen disappear when mouse unhovers the 'area'

#3 Post by stonecold997 »

MaydohMaydoh wrote: Fri Aug 24, 2018 10:54 am Button needs an action for hovered and unhovered to work, so action NullAction() should be give to those buttons.

Code: Select all

screen homeSchedule():
    frame:
       align (0.35, 0.3)
       button action NullAction() unhovered Hide('homeSchedule'):
           
           vbox:
               textbutton "Training Room" action NullAction() hovered Show('homeSchedule')
               textbutton "Library" action NullAction() hovered Show('homeSchedule')


Thanks!!! I've been wondering why only hovering won't work without the action NullAction()... and you pointed out very simply!
I am really thankful. and Yes, the 2nd method is the one I wanted to work and it actually works!!
Thanks alot

stonecold997
Newbie
Posts: 6
Joined: Sun Jul 29, 2018 9:22 am
Contact:

Re: I want to make my screen disappear when mouse unhovers the 'area'

#4 Post by stonecold997 »

ummm... can you explain
The hovered button needs an action part?
I looked up in the document(Screen Action & Screen-Buttons)and found nothing...
isn't action only for the "activated" interaction?
The action to run when the button is activated. A button is activated when it is clicked, or when the player selects it and hits enter on the keyboard. This also controls if the button is sensitive if sensitive is not provided, and if the button is selected if selected is not provided.
Why does it needs NullAction() in order to use hovered and unhovered?
Surely in the document, it says
NullAction(*args, **kwargs)
Does nothing.

This can be used to make a button responsive to hover/unhover events, without actually doing anything.
So hovered and unhovered needs action NullAction() in order to invoke actions.

If button's "action" is only for the "activated" interaction, then action, hovered, and unhovered are all individual actions...

so can't figure out why we need NullAction when hovering and unhovering..
Did I miss somethig in the document?

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Do we need action NullAction() when using hovered and unhovered??

#5 Post by philat »

Because it governs whether the button is sensitive -- i.e., whether it can be hovered/unhovered.

stonecold997
Newbie
Posts: 6
Joined: Sun Jul 29, 2018 9:22 am
Contact:

Re: Do we need action NullAction() when using hovered and unhovered??

#6 Post by stonecold997 »

philat wrote: Sat Aug 25, 2018 3:41 am Because it governs whether the button is sensitive -- i.e., whether it can be hovered/unhovered.

oh... sry... In the document, it says as you say
The action to run when the button is activated. A button is activated when it is clicked, or when the player selects it and hits enter on the keyboard. This also controls if the button is sensitive if sensitive is not provided, and if the button is selected if selected is not provided.
I've read the document before I asked.. but I seem to passed on the quote... I should have kept looking at it. Thanks!
Now I know action controls all of those "Actions"

Post Reply

Who is online

Users browsing this forum: Google [Bot]