Documentation Center

  • Trial Software
  • Product Updates

Contents

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

eventlisteners

List event handler functions associated with COM object events

Syntax

info = h.eventlisteners
info = eventlisteners(h)

Description

info = h.eventlisteners 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 afterwards, using registerevent.

info = eventlisteners(h) is an alternate syntax.

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

Examples

Manage events for an instance of 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'});
h.eventlisteners
ans = 
    'Click'    'myclick'

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

 

Register two more events, DblClick and MouseDown:

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

MATLAB displays all event names and handlers.

 

Unregister all events for the control:

h.unregisterallevents
h.eventlisteners
ans = 
     {}

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

See Also

| | | | |

Was this topic helpful?