get imagebutton position, pass to tooltip-screen

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
Devon Andersson
Newbie
Posts: 7
Joined: Sun Nov 12, 2017 9:10 am
Contact:

get imagebutton position, pass to tooltip-screen

#1 Post by Devon Andersson » Sun Apr 29, 2018 10:09 am

Hello there,

I'd like to add some custom tooltips to my imagebutton. The example below works fine, except that I would have to punch in the same x- and ypos for every tooltip. Is it possible to pass the x- and ypos of the imagebutton itself to my 's_tt'-screen automatically?
I don't know how to replace the hard-coded 500, 400. How to I get the position of the imagebutton here? Is that even possible since it is in the imagebutton-definition itself?

Code: Select all

## TOOLTIP SCREEN
screen s_tt(_text="tooltip", _x=0, _y=0):
    # TODO: adjust position to be centered always (assuming fixed size buttons 64x64)
    fixed:
        xpos _x
        ypos _y
        frame:
            # make frame background translucent
            background "#000A"
            # show tooltip text
            text _text

screen s_test_tooltip():
    imagebutton auto "gui/imagebutton_%s64.png" xpos config.screen_width/2-32 ypos config.screen_height/2-32 action NullAction() hovered Function(renpy.show_screen,"s_tt", "tooltip text", 500, 400) unhovered Hide("s_tt")

label start:
    show screen s_test_tooltip
    "This is just some dummy-text to block and prevent an infite loop ..."
    "An this is a second dummy-text to clearly show the screen was updated."
    jump start

Post Reply

Who is online

Users browsing this forum: Bing [Bot]