| MATLAB Function Reference | ![]() |
Syntax
Description
An hggroup object can be the parent of any axes children, including other hggroup objects. You can use hggroup objects to form a group of objects that can be treated as a single object with respect to the following cases:
Visible property also sets each child object's Visible property to the same value.
HitTest property to off enables you to select all children by clicking any child object.
HitTest property to off enables the hggroup object to become the current object when any child object is picked. See the next section for an example.
Examples
This example defines a callback for the ButtonDownFcn property of an hggroup object. In order for the hggroup to receive the mouse button down event that executes the ButtonDownFcn callback, the HitTest properties of all the line objects must be set to off. The event is then passed up the hierarchy to the hggroup.
The following function creates a random set of lines that are parented to an hggroup object. The subfunction set_lines defines a callback that executes when the mouse button is pressed over any of the lines. The callback simply increases the widths of all the lines by 1 with each button press.
| Note If you are using the MATLAB help browser, you can run this example or open it in the MATLAB editor. |
function doc_hggroup hg = hggroup('ButtonDownFcn',@set_lines); hl = line(randn(5),randn(5),'HitTest','off','Parent',hg); function set_lines(cb,eventdata) hl = get(cb,'Children');% cb is handle of hggroup objectlw = get(hl,'LineWidth');% get current line widthsset(hl,{'LineWidth'},num2cell([lw{:}]+1,[5,1])')
Note that selecting any one of the lines selects all the lines. (To select an object, enable plot edit mode by selecting Plot Edit from the Tools menu.)
Instance Diagram for This Example
The following diagram shows in object hierarchy created by this example.
Setting Default Properties
You can set default hggroup properties on the axes, figure, and root levels.
set(0,'DefaultHggroupProperty',PropertyValue...) set(gcf,'DefaultHggroupProperty',PropertyValue...) set(gca,'DefaultHggroupProperty',PropertyValue...)
where Property is the name of the hggroup property whose default value you want to set and PropertyValue is the value you are specifying. Use set and get to access the hggroup properties.
See Also
Group Objects for more information and examples.
Function Handle Callbacks for information on how to use function handles to define callbacks.
Hggroup Properties for property descriptions
| hgexport | Hggroup Properties | ![]() |
© 1994-2005 The MathWorks, Inc.