Creating Graphical User Interfaces (GUIs), MATLAB Version 7 (R14)

This version introduces the following new features and changes:

New Container Components

MATLAB 7.0 introduces two new container components,

These components are available in the GUIDE Layout Editor and via the functions uipanel and uibuttongroup.

A container component can be the child of a figure or another container. In general, containers can have as children the same components as figures, including other containers. However, they cannot have menu bars, toolbars, or ActiveX controls as children. The Position property of the child of a panel or button group is interpreted relative to the panel or button group. If you move the panel or button group, the components it contains automatically move with it and maintain their positions.

Panel properties and button group properties enable you to control the color, size, border, and position of the panel or button group, assign a title, and specify a context menu. In general, panels and button groups have many of the same properties as uicontrol objects.

For information about working with panels and button groups in GUIDE, see the following topics in the Creating Graphical User Interfaces collection of the MATLAB documentation.

Compatibility Considerations

You can export a GUI that contains a panel or button group from GUIDE to a single M-file that does not require a FIG-file. However, you will not be able to run that M-file in MATLAB versions earlier than 7.0.

ActiveX Controls

GUIDE now enables you to insert an ActiveX control into your GUI if you are running MATLAB on Microsoft Windows. When you drag an ActiveX component from the component palette into the layout area, GUIDE displays a dialog in which you can select any registered ActiveX control on your system. When you select an ActiveX control and click Create, the control appears as a small box in the Layout Editor. You can then program the control to do what you want it to.

See Creating COM Objects in the online MATLAB documentation and ActiveX Controls in the GUIDE documentation to learn more about ActiveX controls.

New Toolbar Component

A new function, uitoolbar, enables you to add a toolbar to a figure. You can add your own pushtools and toggletools to the toolbar with the uipushtool and uitoggletool functions.

Uipushtool properties enable you to provide a callback that responds to a mouse click. Uitoggletool properties enable you to provide callbacks that respond to the tool being set on, off, or toggled to either position. Properties for both uipushtools and uitoggletools provide for tooltip strings, separators, and truecolor images to display on the tools. In general, uitoolbar, uipushtool, and uitoggletool objects have many of the same properties as uicontrol objects.

Menu Editor Enhancements

The GUIDE Menu Editor now enables you to:

The Menu Editor is now better synchronized with other GUIDE tools:

See Menu Editor in the MATLAB documentation for more information.

Layout Resize Behavior

In the GUIDE Layout Editor, components you have placed in the layout area now maintain their visual position relative to the upper left corner of their parent container (figure, panel, or button group) when you resize the container in the Layout Editor. However, the values of the Position property are determined relative to the lower left corner, and these values will change accordingly when you increase or decrease the height of the container.

Key Press Detection

A new uicontrol callback property, KeyPressFcn, specifies a key press callback function with which you can detect a key press when the callback's uicontrol object has focus. If no uicontrol has focus, the figure's key press callback function, if any, is invoked. This property is available in the uicontrol function and in GUIDE.

If you specify the KeyPressFcn property as an M-file, the callback routine can query the figure's CurrentCharacter property to determine what particular key was pressed and ,thereby, limit the callback execution to specific keys. If you specify the KeyPressFcn property as a function handle, the callback routine can retrieve information about the key that was pressed from its eventdata structure argument.

As an example, you can use this property to enable a user to press Enter, rather than the space bar, after giving focus to a uicontrol push button. Use the push button's key press callback function to determine if the user pressed the Enter key. If it was the Enter key, call the push button callback.

See the Uicontrol Properties for more information.

Edit Text Box Scroll Bar

For uicontrol editable text fields, i.e. the Style property is set to 'edit', if Max-Min>1, then multiple lines are allowed. For multi-line edit boxes, a vertical scroll bar enables you to scroll the text. You can also use the arrow keys to scroll.

Setting Uicontrol Focus

The uicontrol function now enables you to transfer focus programmatically to a specified uicontrol object. The syntax uicontrol(uich) transfers focus to the uicontrol object with handle uich.

Multiple Selection in uigetfile

The uigetfile function can now create a dialog that enables the user to select and retrieve multiple files using the Shift and Ctrl keys. You can turn this capability on or off using the new 'MultiSelect' parameter. The default setting is off.

Program Suspension Time-Out

A new uiwait argument, timeout, enables you to specify the number of seconds after which program execution will resume, unless uiresume is called first or the specified figure is deleted. For example,

uiwait(h,5)

causes the suspended program to resume execution, if it has not already, after five seconds.

Standard Dialog Box Push Buttons

For standard dialog boxes with more than one uicontrol push button, you can now give focus to another button while retaining the default button. Focus is denoted by a border or a dotted border, respectively, in UNIX and Microsoft Windows. The default button has a shadow.

In such a case, if the user presses the space bar, the button with focus gets the key press and can choose to execute its own callback or the callback of the default button. If the user presses Enter, the default push button gets the key press and its callback executes. This code provides an example.

ButtonName=questdlg('What is your wish?', ...
                    'Genie Question', ...
                    'Food','Clothing','Money','Money')

New Syntax for uigetfile and uiputfile

The uigetfile and uiputfile syntax that enables you to position dialog boxes that are used to retrieve and save files is changed. The new syntaxes are uigetfile('FilterSpec','DialogTitle','Location',[x y]) and uiputfile('FilterSpec','DialogTitle','Location',[x y]). Previously, the syntaxes were, uigetfile('FilterSpec','DialogTitle',x,y) and uiputfile('FilterSpec','DialogTitle',x,y)

Compatibility Considerations

You are encouraged to change to the new uigetfile and uiputfile syntax. The earlier syntaxes continue to be valid but may be removed in a later release.

Frames Not Available in GUIDE Layout Editor

The frame component no longer appears in the GUIDE Layout Editor component palette. It has been replaced by the panel and button group components. See New Container Components for information about these new components.

Compatibility Considerations

GUIDE continues to support frames in those GUIs that contain them, but it is recommended that you replace them with panels or button groups.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS