This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Interactive Control and Callbacks

Writing programs that respond to user actions, such as mouse clicks

Functions

uicontextmenuCreate context menu
uimenuCreate menu or menu items
dragrectDrag rectangles with mouse
rbboxCreate rubberband box for area selection
refreshRedraw current figure
shgShow most recent graph window

Topics

Callbacks — Programmed Response to User Action

A callback is a function that executes in response to some predefined user action, such as clicking on a graphics object or closing a figure window.

Callback Definition

To use callback properties, assign the callback code to the property.

Capturing Mouse Clicks

There are two properties that determine if and how objects respond to mouse clicks, PickableParts and HitTest.

Button Down Callback Function

Button down callbacks execute when users left-click on the graphics object for which the callback is assigned.

Define a Context Menu

This example shows how to define a context menu, which enable you to provide choices to users for interaction with graphics objects.

Define an Object Creation Callback

This example shows how to define an object creation callback.

Define an Object Deletion Callback

This example shows how to define an object deletion callback.

Pass Mouse Click to Group Parent

This example shows how a group of objects can pass a mouse click to a parent, which operates on all objects in the group.

Pass Mouse Click to Obscured Object

This example shows how to pass mouse clicks to an obscured object.