| External Interfaces Reference |    | 
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:
f = figure ('position', [100 200 200 200]); h = actxcontrol('mwsamp.mwsampctrl.2', [0 0 200 200], f, ... 'sampev'); h.eventlisteners ans = 'click' 'sampev' 'dblclick' 'sampev' 'mousedown' 'sampev'
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:
h.unregisterevent({'dblclick' 'sampev'}); h.eventlisteners ans = 'click' 'sampev' 'mousedown' 'sampev'
This time, register the click and dblclick events with a different event handler for myclick and my2click, respectively:
h.unregisterallevents; h.registerevent({'click' 'myclick'; 'dblclick' 'my2click'}); h.eventlisteners ans = 'click' 'myclick' 'dblclick' 'my2click'
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
|   | unregisterallevents | COM Server Functions |  | 
© 1994-2005 The MathWorks, Inc.