External Interfaces/API Reference |
Register an event handler with a control's event
Syntax
Arguments
h
Handle for a MATLAB COM control object.
callback
Name of an M-function that accepts a variable number of arguments. This function will be called whenever the control triggers an event. Each argument is converted to a MATLAB string. See the section, Writing Event Handlers in the External Interfaces/API documentation for more information on handling control events.
event
Any event associated with h
that can be triggered. Specify event
using the event name.
eventhandler
Name of an M-function that accepts a variable number of arguments. This function will be called whenever the control triggers the event associated with it. See Writing Event Handlers in the External Interfaces/API documentation for more information on handling control events.
Description
Register one or more events with a single callback function or with a separate handler function for each event. 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
).
The strings specified in the callback
, event
, and eventhandler
arguments are not case sensitive.
Examples
Create an mwsamp
control and list all events associated with the control:
f = figure ('pos', [100 200 200 200]); h = actxcontrol ('mwsamp.mwsampctrl.2', [0 0 200 200], f); events(h) ans = Click = void Click() DblClick = void DblClick() MouseDown = void MouseDown(int16 Button, int16 Shift, Variant x, Variant y)
Register all events with the same callback routine, sampev
. Use the eventlisteners function to see the event handler used by each event:
registerevent(h, 'sampev'); eventlisteners(h) ans = 'click' 'sampev' 'dblclick' 'sampev' 'mousedown' 'sampev' unregisterallevents(h);
Register the Click
and DblClick
events with event handlers myclick
and my2click
, respectively:
registerevent(h, {'click' 'myclick'; 'dblclick' 'my2click'}); eventlisteners(h) ans = 'click' 'myclick' 'dblclick' 'my2click'
See Also
events
, eventlisteners
, unregisterevent
, unregisterallevents
, isevent
propedit (COM) | release (COM) |