Currently my tooltip is in a fixed location. I wanted to create an improved tooltip that shows up near the displayable it's hovering over, dynamically.
For now, I do this manually. I place a tooltip like text displayable near the button manually. The problem with this, is if I change the design of the layout, I have to go and change all screen position values all over again.
Code: Select all
# static placement of a tooltip-like text
screen menu_A():
default isButtonBHovered = False
textbutton 'B":
hovered SetVariable('isButtonBHovered', True)
if isButtonBHovered:
frame background None xpos 384 ypos 198:
text 'press key o'
I experimented with doing it via tooltip, but I have to put screen position data inside the tooltip, then filter it out later. But I'd still have to manually edit these values later if the position changes. So this idea is out.
Code: Select all
screen test():
textbutton 'Attack':
tooltip '({xpos 813} {ypos 382}) Attack your enemy.)
Ideally, it would be great if GetToolTip returned the screen position of the displayable it's hovering over.
Code: Select all
screen tooltip_universal():
the_tooltip = GetToolTip()
# the tooltip text of the hovered button
the_tooltip.text
# xpos of the hovered button
the_tooltip.xpos
# ypos of the hovered button
the_tooltip.ypos
# from here, you'd be able to dynamically show helpful tooltips near the button to the user, dynamically.
if tooltip is not None:
text the_tooltip.text :
xpos the_tooltip.xpos
ypos the_tooltip.ypos
I was trying to simulate the above pseudo code by running a function that gets the button's screen position when hovered, with the code I originally posted.
Sure, Renpytom could add this as a feature in the future, but why burden him with it if I could access the screen position of a displayable myself?
The code in the original post is very close to returning the screen pos of the button. Then I can easily show a tooltip dynamically to the user.