Documentation

Contents

eventlisteners

List event handler functions associated with COM object events

Syntax

info = eventlisteners(h)

Description

info = eventlisteners(h) lists the events and their event handler routines registered with COM object h. The function returns a cell array of strings info, with each row containing the name of a registered event and the handler routine for that event. If the object has no registered events, eventlisteners returns an empty cell array. You can register events either when you create the control, using actxcontrol, or at any time afterward, using registerevent.

COM functions are available on Microsoft® Windows® systems only.

Examples

This example manages events for the MATLAB® control, mwsamp.

f = figure('position',[100 200 200 200]);
% Create an mwsamp control and 
% register the Click event
h = actxcontrol('mwsamp.mwsampctrl.2',...
    [0 0 200 200],f,{'Click' 'myclick'});
eventlisteners(h)
ans = 
    'Click'    'myclick'

MATLAB displays the event name and its event handler, myclick.

Register two more events, DblClick and MouseDown:

registerevent(h,{'DblClick', 'my2click'; 'MouseDown' 'mymoused'});
eventlisteners(h)
ans = 
    'Click'        'myclick' 
    'Dblclick'     'my2click'
    'Mousedown'    'mymoused'

MATLAB displays all event names and handlers.

Unregister all events for the control:

unregisterallevents(h)
eventlisteners(h)
ans = 
     {}

MATLAB displays an empty cell array, indicating the control has no registered events.

Was this topic helpful?