External Interfaces Reference Previous page   Next Page
registerevent

Register event handler with control's event

Syntax

Description

h.registerevent(event_handler) registers certain event handler routines with their corresponding events. Once an event is registered, the control responds to the occurrence of that event by invoking its event handler routine. The event_handler argument can be either a string that specifies the name of the event handler function, or a function handle that maps to that function.

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

You can either register events at the time you create the control (using actxcontrol), or register them dynamically at any time after the control has been created (using registerevent). Both events and event handlers are specified in the event_handler argument (see "Specifying Event Handlers" in the External Interfaces documentation).

Examples

Example 1

Create an mwsamp control and list all events associated with the control:

Register all events with the same event handler routine, sampev. Use the eventlisteners function to see the event handler used by each event:

Register the Click and DblClick events with event handlers myclick and my2click, respectively:

Example 2

Register all events with the same event handler routine, sampev, but use a function handle (@sampev) instead of the function name:

See Also

events, eventlisteners, unregisterevent, unregisterallevents, isevent


Previous page  propedit release Next page

© 1994-2005 The MathWorks, Inc.