Skip to main content
Known Participant
Apr 27, 2009 5:10 AM UTC
Answered

Block link event handling

Is it possible to block the event handling so that if the user clicks on a link nothing happens? I want to validate links and provide the ability to create internal links that navigate within the application, but no matter what parameters I change on the event listener for the click event on the textFlow it always tells the browser to go to the link location.

Thanks in advance.

This topic is closed to new replies. Start a new post to keep the conversation going.
robin_briggsCorrect answer
Adobe Employee
May 15, 2009 11:07 PM UTC

I've discovered that there is a way to do this. If you listen for the CLICK event, then handle it yourself and call preventDefault() on the event, there will be no default handling of the link (i.e., it won't bring up the browser).

So in your event handler, where you listen for MouseEvent.CLICK from the LinkElement, add something like this:

           if (event.type == MouseEvent.CLICK)

          {

               ... your handling goes here ...
               event.preventDefault();

          }

Sorry I didn't see this earlier. Hope it helps!

- robin

3 replies

Adobe Employee
Apr 28, 2009 12:31 AM UTC

I don't know of a way to do this now, but I agree that there should be one. We'll look into it.

Translate
robin_briggsCorrect answer
Adobe Employee
May 15, 2009 11:07 PM UTC

I've discovered that there is a way to do this. If you listen for the CLICK event, then handle it yourself and call preventDefault() on the event, there will be no default handling of the link (i.e., it won't bring up the browser).

So in your event handler, where you listen for MouseEvent.CLICK from the LinkElement, add something like this:

           if (event.type == MouseEvent.CLICK)

          {

               ... your handling goes here ...
               event.preventDefault();

          }

Sorry I didn't see this earlier. Hope it helps!

- robin

Translate
Known Participant
May 16, 2009 9:26 AM UTC

Thank you very much. It works perfectly.

Translate