External Interfaces Reference Previous page   Next Page
unregisterevent

Unregister event handler with control's event

Syntax

Description

h.unregisterevent(event_handler) unregisters certain event handler routines with their corresponding events. Once you unregister an event, the control no longer responds to any further occurrences of the event.

unregisterevent(h, event_handler) is an alternate syntax for the same operation.

You can unregister events at any time after a control has been created. Both events and event handlers are specified in the event_handler argument (see "Specifying Event Handlers" in the External Interfaces documentation).

You must specify events in the event_handler argument using the names of the events. Unlike the actxcontrol and registerevent functions, unregisterevent does not accept numeric event identifiers.

Examples

Create an mwsamp control and register all events with the same handler routine, sampev. Use the eventlisteners function to see the event handler used by each event. In this case, each event, when fired, will call sampev.m:

Unregister just the dblclick event. Now, when you list the registered events using eventlisteners, you see that dblclick is no longer registered. The control will no longer respond when you double-click the mouse over it:

This time, register the click and dblclick events with a different event handler for myclick and my2click, respectively:

You can unregister these same events by specifying event names and their handler routines in a cell array. Note that eventlisteners now returns an empty cell array, meaning that no events are registered for the mwsamp control:

In this last example, you could have used unregisterallevents instead:

See Also

events, eventlisteners, registerevent, unregisterallevents, isevent


Previous page  unregisterallevents COM Server Functions Next page

© 1994-2005 The MathWorks, Inc.