Monday, August 3, 2009

eventlisteners (COM)

Return a list of events attached to listeners

Syntax

  • eventlisteners(h)

Arguments

h
Handle for a MATLAB COM control object.

Description

eventlisteners lists any events, along with their callback or event handler routines, that have been registered with control, h. The function returns a cell array of strings, with each row containing the name of a registered event and the handler routine for that event. If the control has no registered events, then eventlisteners returns an empty cell array.

Events and their callback or event handler routines must be registered in order for the control to respond to them. You can register events either when you create the control, using actxcontrol, or at any time afterwards, using registerevent.

Examples

Create an mwsamp control, registering only the Click event. eventlisteners returns the name of the event and its event handler routine, myclick:

  • f = figure('pos', [100 200 200 200]);
    h = actxcontrol('mwsamp.mwsampctrl.2', [0 0 200 200], f, ...
    {'Click' 'myclick'});

    eventlisteners(h)
    ans =
    'click' 'myclick'

Register two more events: DblClick and MouseDown. eventlisteners returns the names of the three registered events along with their respective handler routines:

  • registerevent(h, {'DblClick', 'my2click'; ...
    'MouseDown' 'mymoused'});

    eventlisteners(h)
    ans =
    'click' 'myclick'
    'dblclick' 'my2click'
    'mousedown' 'mymoused'

Now unregister all events for the control, and eventlisteners returns an empty cell array, indicating that no events have been registered for the control:

  • unregisterallevents(h)

    eventlisteners(h)
    ans =
    {}





events (COM)

Return a list of events that the control can trigger

Syntax

  • events(h)

Arguments

h
Handle for a MATLAB COM control object.

Description

Returns a structure array containing all events, both registered and unregistered, known to the control, and the function prototype used when calling the event handler routine. For each array element, the structure field is the event name and the contents of that field is the function prototype for that event's handler.

    Note The send function is identical to events, but send will be made obsolete in a future release.

Examples

Create an mwsamp control and list all events:

  • f = figure ('pos', [100 200 200 200]);
    h = actxcontrol ('mwsamp.mwsampctrl.2', [0 0 200 200], f);

    events(h)
    Click = void Click()
    DblClick = void DblClick()
    MouseDown = void MouseDown(int16 Button, int16 Shift,
    Variant x, Variant y)

Or assign the output to a variable and get one field of the returned structure:

  • ev = events(h);

    ev.MouseDown
    ans =
    void MouseDown(int16 Button, int16 Shift, Variant x, Variant y)

No comments:

Post a Comment