I haven't tested this uber thoroughly, so adapt if needed; here's my adjustment to the code in the GitHub:
init python:
class MouseTooltip(Tooltip, renpy.Displayable):
"""A Tooltip whose x/y position follows the mouse's."""
action = Action
def __init__(self, default, padding=None, virtual_cursor=None, *args, **kwargs):
super(renpy.Displayable, self).__init__(*args, **kwargs)
self.default = default
self.value = default
self.padding = padding or {}
self.pad_x = self.padding.get('x', 0)
self.pad_y = self.padding.get('y', 0)
self.x = 0
self.y = 0
self.virtual_cursor = virtual_cursor
def render(self, width, height, st, at):
# Only Text() displayables have a size method
try:
w, h = self.value.size()
except AttributeError:
child_render = renpy.render(self.value, width, height, st, at)
w, h = child_render.get_size()
render = renpy.Render(w, h)
render.place(self.value, x=self.x + self.pad_x, y=self.y + self.pad_y)
return render
def event(self, ev, x, y, st):
if self.virtual_cursor and not pad_config.is_using_mouse():
d = renpy.get_widget(None, self.virtual_cursor)
if d is None:
raise Exception("There is no displayable with the id {}.".format(self.virtual_cursor))
x, y = d.get_cursor_coords()
if x != self.x:
renpy.redraw(self, 0)
if y != self.y:
renpy.redraw(self, 0)
self.x = x
self.y = y
# Pass the event to our child
return self.value.event(ev, x, y, st)
image test_cursor_image = Text("↖", prefer_emoji=False,
font="DejaVuSans.ttf", size=90, color="#FFF",
outlines=[(2, "#000")])
default mtt = MouseTooltip(Text("No button selected."), padding={"x": 10, "y": -10}, virtual_cursor="vc_test")
screen test_tooltips():
add mtt
virtual_cursor:
id 'vc_test'
cursor ("test_cursor_image", 12, 30)
vbox:
align (0.5, 0.5) spacing 20
textbutton "One.":
action Notify("1")
hovered mtt.Action(Text("The loneliest number."))
textbutton "Two.":
action Notify("2")
hovered mtt.Action(Text("Is what it takes."))
textbutton "Three.":
action Notify("3")
hovered mtt.Action(Text("A crowd."))
textbutton "Hearts.":
action Notify("3")
hovered mtt.Action(Image("icons8-heart-outline-48.png"))
The main thing is you will need to provide your virtual cursor with an ID, and then pass that ID to your MouseTooltip (mine's "vc_test"). Also I cleaned up whatever was going on with that code's redrawing functions, as they were not working properly.