In that experiment that i'm making, i have a long label inside scrollview where i print text within canvas_drawed icons
(i will tomorrow try to use an "add_wdiget(Image ... )" inside the label - seems prettier if the label get resized etc)
I use a "[ref=%s] [/ref]" % number, to find where to place the icon (yes a bit row, but they're all small icons)
Basically, the coords returned in Label.refs, are top-left coordinate... i'm using a fixed size label, but i think it would do the same
with a size_hint placed Label.
i wrote a function like these for know if the mouse/touch is over a ref:
(copied from kivy.uix.label on_touch_down line ~208 and rearranged)
def is_ref(self,touch):
# self is the scrollview, self.lbl the label inside the scrollview
tx, ty = touch.pos
# as i understand, here they're subtracting the position of the upper-left corner, to have a
# relative coordinate to the label
tx -= self.center_x - self.lbl.texture_size[0] / 2.
ty -= self.center_y - self.lbl.texture_size[1] / 2.
# and here "invert" the y
ty = self.lbl.texture_size[1] - ty
# below is almost the same as found in on_touch_down
for uid, zones in self.lbl.refs.items():
for zone in zones:
x, y, w, h = zone
if x <= tx <= w and y <= ty <= h:
return uid
return False
i hope it helps :)
i've looked a bit inside core.text.markup, but i should look in deeper ..
then, i discovered treeview and popup and .... too many good things :P