COM Event Handlers
Use registerevent
to register server events. Use
events
to list all the events a COM object recognizes.
Arguments Passed to Event Handlers
When a registered event is triggered, MATLAB® passes information from the event to its handler function, as shown in the following table.
Arguments Passed by MATLAB Functions
Arg. No. | Contents | Format |
---|---|---|
| Object name | MATLAB
|
| Event ID |
|
| Start of Event Argument List | As passed by the control |
| End of Event Argument List (Argument N) | As passed by the control |
| Event Structure |
|
| Event Name |
|
When writing an event handler function, use the Event Name argument to identify
the source of the event. Get the arguments passed by the control from the Event
Argument List (arguments 3
through end-2
). All
event handlers must accept a variable number of arguments:
function event (varargin) if (strcmp(varargin{end}, 'MouseDown')) % Check the event name x_pos = varargin{5}; % Read 5th Event Argument y_pos = varargin{6}; % Read 6th Event Argument end
Note
The values passed vary with the particular event and control being used.
Event Structure
The Event Structure argument passed by MATLAB contains the fields shown in the following table.
Fields of the Event Structure
Field Name | Description | Format |
---|---|---|
| Event Name |
|
| Control Name | MATLAB
|
| Event Identifier |
|
| Event Arg Value 1 | As passed by the control |
| Event Arg Value 2 | As passed by the control |
etc. | Event Arg N | As passed by the control |