Intercepting and blocking mouse events


Is there an elegant way to block mouse events from reaching a component?

I can intercept them easily enough by registering another mouse listener with the component, but even if it were possible to destroy the mouse event at that point, I have no way of knowing whether the mouse message has already reached the component.

Basically I just want to be able to listen into mouse events that occur to a component and occassionally trap them for some other purpose.


You can override hitTest() to avoid getting any events… or if you want to know about them, you could just stick a transparent component over the top and use that to catch them?


The hitTest() method on the base component wont work for me 'cos I don’t want any relationship between the component and the class that is listening to it.

I hadn’t really considered overlaying a clear panel because I need fairly fast graphic updates on the base component (icky medical images). Thinking on it though, the extra component really shouldn’t add much weight, and overriding hitTest() there would in principal work perfectly for what I need.

I’ll give it a try. Cheers Jules.

BTW the array classes are just saving me hours of donkey work. I’m quite enjoying my day job again. :wink:


Adding a component that doesn’t do any drawing won’t slow it down at all - the only overhead would be a call to its empty paint() method - maybe a couple of microseconds…