Skip to main content
Known Participant
April 27, 2009
Answered

Block link event handling

  • April 27, 2009
  • 1 reply
  • 1029 views

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 has been closed for replies.
Correct answer robin_briggs

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

1 reply

Adobe Employee
April 28, 2009

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

robin_briggsCorrect answer
Adobe Employee
May 15, 2009

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

Known Participant
May 16, 2009

Thank you very much. It works perfectly.