why this code auto-scrolled up to top when I click button in the area

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
socradeath
Newbie
Posts: 7
Joined: Sat Feb 09, 2019 2:09 am
Contact:

why this code auto-scrolled up to top when I click button in the area

#1 Post by socradeath » Sat Feb 09, 2019 2:25 am

Hello, This is my first renpy programming.

I want scroll bar to keep position when click the button in the area, but when I click the button, the scroll bar is rolled up to the top position
I couldn't find what's the wrong in this code

Code: Select all

screen charinfo(filter_list):
    
    tag info
    frame:
        xalign 0.78
        yalign 0.562
        side("c r"):
            area (0,0,400,520)

            viewport id "charinfo_scroller":
                draggable True mousewheel True
                vbox:
                    spacing 2
                    for i in characters :
                        if i.state in filter_list :

                            frame:
                                button:
                                    xminimum 379
                                    yminimum 120
                                    style "buttonz"
                                    action Show("profile",ch=i)
                                    hbox:
                                        spacing 10
                                        image i.profile at profilzoom

                                        vbox:
                                            
                                            text str(i.name) size 25
                                            text str(i.age)+"age" size 15
                                            text i.state size 20
                                            text str(i.set_pay())+"pay" size 20


            vbar value YScrollValue("charinfo_scroller")


socradeath
Newbie
Posts: 7
Joined: Sat Feb 09, 2019 2:09 am
Contact:

Re: why this code auto-scrolled up to top when I click button in the area

#2 Post by socradeath » Sat Feb 09, 2019 2:52 am

ps. now i found one weird thing about the problem. first time i click one of the buttons, scroll bar keep it's position, but second time and after second time i click the buttons, scroll bar is set to the top position.

socradeath
Newbie
Posts: 7
Joined: Sat Feb 09, 2019 2:09 am
Contact:

Re: why this code auto-scrolled up to top when I click button in the area

#3 Post by socradeath » Sat Feb 09, 2019 3:07 am

and now I found one clue. when I change the line "action Show("profile",ch=i)" to "action NullAction()", problem disappeared.
but, profile screen has no problem...

because I change the line "action Show("profile",ch=i)" to "action Show("fake_profile",ch=i)", problem still appeared.

Code: Select all

screen fake_profile(ch):
    tag charinfo
    pass


socradeath
Newbie
Posts: 7
Joined: Sat Feb 09, 2019 2:09 am
Contact:

Re: why this code auto-scrolled up to top when I click button in the area

#4 Post by socradeath » Sat Feb 09, 2019 3:31 am

OK, I solved this problem.
"tag charinfo" makes this error. I change the tag name another one, and problem solved. but still I can't understand why tag makes problem.
is there any correlation between tag name and screen name?
Shoud am I careful for naming tag?

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: why this code auto-scrolled up to top when I click button in the area

#5 Post by Alex » Sat Feb 09, 2019 7:51 am

It looks like, because of renpy.get_screen (https://www.renpy.org/doc/html/screen_p ... get_screen) that is used in Show action (see 00action_control.rpy in renpy/common folder)

socradeath
Newbie
Posts: 7
Joined: Sat Feb 09, 2019 2:09 am
Contact:

Re: why this code auto-scrolled up to top when I click button in the area

#6 Post by socradeath » Sat Feb 09, 2019 9:42 am

Alex wrote:
Sat Feb 09, 2019 7:51 am
It looks like, because of renpy.get_screen (https://www.renpy.org/doc/html/screen_p ... get_screen) that is used in Show action (see 00action_control.rpy in renpy/common folder)
oh, i see.
then I should be careful. - do not use name of other screens as tag name.
Thank you.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]