Swapping of event handlers

J

Jan van Schalkwyk

Hi,

I want to replace an event handler on an outside control with a new handler,
and then later swap back to the old handler again... Is there any way to do
it? (I'll have to store the old handler, but how on earth can I do it?)

If it may help, what I want to do is the following: I have a GIS map, and I
want to create a few tools that can be used on the map. When you activate a
specific tool, the mouse up, down move events must be processed by my tool,
and any other handlers in the "main" code must not be executed. When the
tool is deactivated, the old handlers must be hooked up again.

I can add my own handler with +=, and remove it again afterwards (-=), but I
don't know how to "save" the existing events in the collection (I suppose it
is an event collection)?

Thanks
Jan
 
F

Fabio Cannizzo

I would crate a control which inherits form the one you are working on.

Then override onMouseDown().

An event will be raised only if inside onMouseDown() you call
base.onMouseDown(...).

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top