MATLAB Creating Graphical User Interfaces

(Barry) #1
Create Toolbars for GUIDE UIs

Predefined and Custom Tools


The Toolbar Editor provides two types of tools:



  • Predefined tools, having standard icons and behaviors

  • Custom tools, having generic icons and no behaviors


Predefined Tools


The set of icons on the bottom of the Tool Palette represent standard MATLAB figure
tools. Their behavior is built in. Predefined tools that require an axes (such as pan and
zoom) do not exhibit any behavior in UIs lacking axes. The callback(s) defining the
behavior of the predefined tool are shown as %default, which calls the same function
that the tool calls in standard figure toolbars and menus (to open files, save figures,
change modes, etc.). You can change %default to some other callback to customize the
tool; GUIDE warns you that you will modify the behavior of the tool when you change a
callback field or click the View button next to it, and asks if you want to proceed or not.


Custom Tools


The two icons at the top of the Tool Palette create pushtools and toggletools. These
have no built-in behavior except for managing their appearance when clicked on and
off. Consequently, you need to provide your own callback(s) when you add one to your
toolbar. In order for custom tools to respond to clicks, you need to edit their callbacks to
create the behaviors you desire. Do this by clicking the View button next to the callback
in the Tool Properties pane, and then editing the callback in the Editor window.


Add and Remove Separators


Separators are vertical bars that set off tools, enabling you to group them visually. You
can add or remove a separator in any of three ways:



  • Right-click on a tool's preview and select Show Separator, which toggles its
    separator on and off.

  • Check or clear the check box Separator to the left in the tool's property pane.

  • Change the Separator property of the tool from the Property Inspector


After adding a separator, that separator appears in the Toolbar Layout to the left of
the tool. The separator is not a distinct object or icon; it is a property of the tool.


Move Tools


You can reorder tools on the toolbar in two ways:

Free download pdf