Skip to main content
Known Participant
Jun 21, 2010 4:29 AM UTC
Question

How to modify contextMenu for LinkElement only?

I want to modify the default contextMenu for LinkElement only.

I think that I might do this by overriding ContainerController.menuSelectHandler() method. But how can i know what kind of element was being right-clicked?  I just want add some contextMenuItem to when user click LinkElement.

Thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Inspiring
Jun 21, 2010 8:30 PM UTC

This formula should work with some adjusments (I didn't try it):  In your ContainerController.menuSelectHandler override container.mouseX and container.mouseY contain the mouse position.  From that use static SelectionManager method computeSelectionIndex(textFlow, container, container, container.mouseX, container.mouseY) to compute an index in the TextFlow.  computeSelectionIndex is in the tlf_internal namespace and is not documented.  Then use textFlow.findleaf(index) to find the leaf element.  Check the returned leaf's parents to see if its in a LinkElement and customize your contextMenu as desired.

Hope that helps,

Richard

Translate
fatmckAuthor
Known Participant
Jun 22, 2010 8:31 AM UTC

Thanks a lot, it seems to be a little complicated..I'll try.

Translate