Creating clickable links within text

35 views
Skip to first unread message

Joel

unread,
May 21, 2013, 3:51:10 PM5/21/13
to google-we...@googlegroups.com
I have a cell that contains some text. I would like to create links within the text that are clickable.

"For, example abc and xyz should be links."

I figured on using InlineLabel to create the links within the text. However, since the whole thing is a cell I can't click on the individual label/links. 

1) Is there a way to turn off "click grabbing" at the CellList level, so my inner links will work? I also need to know which one was clicked? How?
2) Is InlineLabel really the appropriate widget to use (I just want to take an action on the page, not leave the page)?  

J

Thomas Broyer

unread,
May 22, 2013, 4:14:27 AM5/22/13
to google-we...@googlegroups.com


On Tuesday, May 21, 2013 9:51:10 PM UTC+2, Joel wrote:
I have a cell that contains some text. I would like to create links within the text that are clickable.

"For, example abc and xyz should be links."

I figured on using InlineLabel to create the links within the text. However, since the whole thing is a cell I can't click on the individual label/links. 

1) Is there a way to turn off "click grabbing" at the CellList level, so my inner links will work? I also need to know which one was clicked? How?

Your "links" will be <span>s with specific class names, and in onBrowserEvent you'll check whether the event target is on of those spans and take action accordingly. Using UiRenderer will make it easier if you can use it: http://www.gwtproject.org/doc/latest/DevGuideUiBinder.html#Rendering_HTML_for_Cells

2) Is InlineLabel really the appropriate widget to use (I just want to take an action on the page, not leave the page)?

No, just like any widget. You use Cells, so you can't use widgets (within them).

Joel

unread,
May 22, 2013, 12:51:03 PM5/22/13
to google-we...@googlegroups.com
Thanks for the response. I made some progress, like you say the trick is mostly in processing the DOM in the onBrowserEvent. I also had the issue of the pointer/selection trying to be handled by the CellList, this requires un-styling it appropriately and turning off selection mode:

    cellList.setSelectionModel(new NoSelectionModel<ReviewEntry>(),
            DefaultSelectionEventManager.<ReviewEntry>createWhitelistManager());

Propagating the click events will be a little interesting as well as conditionally constructing these links in the cell renderer, but the end state is in sight.

Thanks!,
J
Reply all
Reply to author
Forward
0 new messages