2

I've got a ClutterText object that I'd like to make display a clickable hyperlink. ClutterText has the option to use Pango markup but apparently not a way to mark a hyperlink.

Is there an easy way of doing this?

Kazade
  • 1,297
  • 2
  • 15
  • 25

1 Answers1

3

the MeeGo Netbook user experience had a ClutterText sub-class that allowed highlighting and clicking URLs:

https://github.com/meego-netbook-ux/meego-panel-myzone/blob/master/penge/penge-clickable-label.c

the basics are:

  • detect the boundaries of the URL inside the text (using a regular expression, generally);
  • use PangoAttributes to change the style (underline + color);
  • use the button-release-event signal, or the captured-event one if you want to allow other behaviours, to detect where the user has clicked inside the PangoLayout of the ClutterText;
  • if the coordinates of the button event are within the boundaries of the link then success: emit a signal or call a function to handle the URL.

remember to make the ClutterText actor reactive if you want it to handle events. :-)

elboulangero
  • 818
  • 9
  • 18
ebassi
  • 8,648
  • 27
  • 29