ContentsIndexReferenceHome
PreviousUpNext
mkdraggable
MATLAB
mkdraggable(h,[motionfcn],[constraint],[p],[turnOff])
Description

Make it so that a graphics object can be dragged in a figure. This function makes an object interactive by allowing it to be dragged across a set of axes, following or not certain constraints. This allows for intuitive control elements which are not buttons or other standard GUI objects, and which reside inside an axis. Typical use involve markers on an axis, whose position alters the output of a computation or display.

Parameters
Parameters 
Description 
h [array] 
Handle or array of handles for objects to make draggable 
motionfcn [function handle] 
(Optional) Function to be executed while object is being dragged. 
constraint [string] 
(Optional) Identifier used to constrain motion. Can be one of 'n' or 'none' (the object is unconstrained (default)), 'h' or 'horizontal' (the object can only be moved horizontally), or 'v' or 'vertical' (the object can only be moved vertically) 
p [vector] 
(Optional) Limits to apply to the selected constraint. Defaults to the limits of the axes. 
turnOff [string] 
(Optional) 'Off' to turn dragging off. 
Examples

  • mkdraggable(h)
    • Makes the object with handle "h" draggable.
  • mkdraggable(h,motionfcn)
    • Where "motionfcn" is a function handle, executes the given function while the object is dragged. Handle h is passed to motionfcn as an argument. Argument "motionfcn" can be put anywhere after handle "h"
  • mkdraggable(h,'v',[0 1])
    • Allows the object to be dragged vertically between 0 and 1
  • mkdraggable(h,'off')
    • Turns off dragging of h
Adapted from draggable.m written by Francois Bouffard and obtained from MathWorks File Exchange.

Group
Made with Doc-O-Matic.
Copyright (c) MZA Associates 2009. All rights reserved.
What do you think about this topic? Send feedback!