banner



app designer drop down menu

Drop-Down (App Designer) Properties

Control drop-down component appearance and behavior

Valid for drop-down components created with App Designer or the uidropdown function. For drop—down components created with GUIDE or the uicontrol function, see Uicontrol Properties.

Drop-down components are UI components that enable the app user to select an option or type in text. Typically, an action occurs when the app user changes the selection or enters a value. Use properties to control the appearance and behavior of a drop-down component. To refer to a particular object and property, use dot notation:

f = uifigure; dd = uidropdown(f); txt = dd.Items; dd.Items = {'Amoxicillian','Erythromycin',...             'Penecillin','Tobramycin', };              

Value

expand all

Drop-down component value, specified as an element of the Items or ItemsData cell array or the app-user-entered value. The default is the first element of the Items array.

  • If ItemsData is empty, Value is the selected element of Items.

  • If ItemsData is not empty, Value is the element in ItemsData that corresponds to the selected element of Items

The app user can type values in the drop-down component if the Editable property value is 'on'.

Programmatic Changes When ItemsData Is Empty

Suppose all of the following are true:

  • The Items property value is {'Red','Blue','Green'}.

  • The ItemsData value is empty.

  • The app user has the second element, Blue, selected from the drop-down component.

If the Items value changes programmatically to {'Pink','Blue','Aqua'}, then the element selected before the programmatic change is an element of the updated Items value. In this case, the Value remains 'Blue' and the selection remains the second drop-down component element.

If the Items value changes programmatically to {'Red','Teal','Green'}, then the drop-down component element selected before the programmatic change is not an element of the updated Items value. In this case, the Value becomes the first element of the Items value ('Red') and the selection becomes the first drop-down component element.

Programmatic Changes When ItemsData Is Not Empty

Suppose all of the following are true:

  • The Items value is {'Red','Blue','Green'}.

  • The ItemsData value is originally [10 20 30].

  • The app user has the second element, Blue, selected from the drop-down component before the programmatic change.

If the ItemsData property changes programmatically to [0 10 20], then the app user selection corresponds to an element of ItemsData that is the same before and after the programmatic change (20). However, 20 now corresponds to the third Items element. So the third drop-down component element (Blue) is selected, even though the Value remains unchanged.

If the ItemsData property changes programmatically to [10 100 1000], then the app user selection corresponds to an element of ItemsData that no longer exists. In this case, the Value becomes the first element of ItemsData (10) and the first drop-down component item (Red) is selected.

Programmatic Changes Resulting in Duplicate ItemsData Values

Suppose all of the following are true:

  • The Items value is {'Red','Blue','Green'}.

  • The ItemsData value is originally [10 20 20].

  • The app user has the first element, 'Red', selected from the drop-down component before the programmatic change.

If the Value property changes programmatically to 20, then the drop-down component selection becomes the first element of Items that matches that value, namely, 'Blue'.

Drop-down component options presented to the app user, specified as a 1-by-n cell array of character vectors. Duplicate elements are allowed. The drop-down component displays as many options as there are elements in the Items property value.

Example: {'Red','Yellow','Blue'}

Example: {'1','2','3'}

Data associated with each element of the Items property value, specified as a 1-by-n numeric array or a 1-by-n cell array. Duplicate elements are allowed.

For example, if you set the Items value to employee names, you might set the ItemsData value to corresponding employee ID numbers. The ItemsData value is not visible to the app user.

If the number of array elements in the ItemsData value and the Items value do not match, one of the following occurs:

  • When the ItemsData value is empty, then all the elements of the Items value are presented to the app user.

  • When the ItemsData value has more elements than the Items value, then all the elements of the Items value are presented to the app user. MATLAB® ignores the extra ItemsData elements.

  • When the ItemsData value is not empty, but has fewer elements than the Items value, the only elements of the Items value presented to the app user are those that have a corresponding element in the ItemsData value.

Example: {'One','Two','Three'}

Example: [10 20 30 40]

Appearance

expand all

Drop-down component background color, specified as an RGB triplet, short name, or long name. The color you specify fills the area bounded by the drop-down component.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7]. This table lists RGB triplet values that have equivalent color names.

Long Name Short Name RGB Triplet
'yellow' 'y' [1 1 0]
'magenta' 'm' [1 0 1]
'cyan' 'c' [0 1 1]
'red' 'r' [1 0 0]
'green' 'g' [0 1 0]
'blue' 'b' [0 0 1]
'white' 'w' [1 1 1]
'black' 'k' [0 0 0]

Example: [0 0 1]

Example: 'b'

Example: 'blue'

Drop-down component visibility, specified as 'on' or 'off'. The Visible property determines whether the drop-down component is displayed on the screen. If the Visible property is set to 'off', then the drop-down component is hidden, but you can still specify and access its properties.

To make your app start faster, set the Visible property of all components that do not need to appear at startup to 'off'.

Location and Size

expand all

Location and size of the drop-down component relative to the parent, specified as the vector [left bottom width height]. This table describes each element in the vector.

Element Description
left Distance from the inner left edge of the parent container to the outer left edge of the drop-down component
bottom Distance from the inner bottom edge of the parent container to the outer bottom edge of the drop-down component
width Distance between the right and left outer edges of the drop-down component
height Distance between the top and bottom outer edges of the drop-down component

All measurements are in pixel units.

    Note:   The Position values are relative to the drawable area of the parent container component (UI figure, button group, panel, or tab). The drawable area of a container component is the area inside its borders, excluding the title bar.

Example: [100 100 100 22]

Inner location and size of the drop-down component, specified as [left bottom width height]. Position values are relative to the parent container. All measurements are in pixel units. This property value is identical to Position for drop-down components.

This property is read only.

Outer location and size of drop-down component returned as [left bottom width height]. Position values are relative to the parent container. All measurements are in pixel units. This property value is identical to Position for drop-down components.

Font Style

expand all

Font in which to display the Items property value elements, specified as a system supported font name. The default font depends on the specific operating system and locale.

If the specified font is not available, then MATLAB uses the best match among the fonts available on the system where the app is running.

Example: 'Arial'

Font size of Items property value elements, specified as a positive number. The units of measurement are pixels.

Example: 14

Color of the Items property value, specified as an RGB triplet, long name, or short name.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long Name Short Name RGB Triplet
'yellow' 'y' [1 1 0]
'magenta' 'm' [1 0 1]
'cyan' 'c' [0 1 1]
'red' 'r' [1 0 0]
'green' 'g' [0 1 0]
'blue' 'b' [0 0 1]
'white' 'w' [1 1 1]
'black' 'k' [0 0 0]

Example: [0.4 0.6 0.7]

Thickness of the Items property value, specified as one of these values:

  • 'normal' — Default weight as defined by the particular font

  • 'bold' — Thicker character outlines than 'normal'

Not all fonts have a bold font weight. Therefore, specifying a bold font weight can result in the normal font weight.

Character slant of the Items property value, specified as 'normal' or 'italic'. Setting this property to italic selects a slanted version of the font, if it is available on the app user's system.

Interactive Control

expand all

Code to execute when the app user changes the drop-down component selection, specified as a function handle, a cell array containing a function handle and additional arguments, or a character vector.

If you specify this property as a function handle (or cell array containing a function handle), MATLAB passes an event object containing callback data as an argument to the callback function. This object contains the properties described in the following table. You can access these properties inside the callback function using dot notation.

Event Property Value
Edited Logical value (0 or 1) that indicates whether the callback was executed as a result of typing a value into the drop-down component. The Edited value is 1 when the app user typed in the drop-down component and 0 when the app user selected an option from the drop-down component.
EventName 'ValueChanged'
PreviousValue Drop-down component value before app user's most recent interaction with it.
Source Handle to the drop-down component associated with the ValueChangedFcn callback.
Value Drop-down component value after app user's most recent interaction with it.

For example, to display the previous and current values of the drop-down component in the MATLAB Command Window, specify this code in the ValueChangedFcn callback.

event.PreviousValue event.Value                        

This callback does not execute if the app user clicks the currently selected option, or if the Value property setting changes programmatically.

Example: @myfunc

Example: {@myfunc, x}

Editable state of the drop-down component, specified as 'off' or 'on'.

If the Enable property value is 'off', then the app user cannot change the drop-down component text, even if the Editable property value is 'on'.

Operational state of the drop-down component , specified as 'on' or 'off'.

  • If you set this property value to 'on', then the appearance of the drop-down component indicates that the app user can change the drop-down component value.

  • If you set this property value to 'off', then the appearance of the drop-down component appears dimmed. This appearance indicates that the app user cannot change the drop-down component value, and that the drop-down component will not trigger any callbacks.

Callback Execution Control

expand all

Callback interruptibility status, specified as 'on' or 'off'. The Interruptible property determines if a running callback can be interrupted.

There are two callback states to consider:

  • The running callback is the currently executing callback.

  • The interrupting callback is a callback that tries to interrupt the running callback.

Whenever MATLAB invokes a callback, that callback attempts to interrupt the running callback. The Interruptible property of the object owning the running callback determines if interruption is allowed. If interruption is not allowed, then the BusyAction property of the object owning the interrupting callback determines if it is discarded or put into a queue.

If a callback is the running callback, then the Interruptible property determines if it can be interrupted by another callback. The Interruptible property has two possible values:

  • 'off' — A callback cannot interrupt the running callback. MATLAB finishes executing the running callback without any interruptions. This is the default behavior.

  • 'on' — A callback can interrupt the running callback. The interruption occurs at the next point where MATLAB processes the queue, such as when there is a drawnow, uifigure, getframe, waitfor, or pause command.

    • If the running callback contains one of the commands, then MATLAB stops the execution of the callback at this point and executes the interrupting callback. MATLAB resumes executing the running callback when the interrupting callback completes.

    • If the running callback does not contain one of these commands, then MATLAB finishes executing the callback without interruption.

    Note:   Callback interruption and execution behave differently in these situations:

    • If the interrupting callback is a DeleteFcn, CloseRequestFcn or SizeChangedFcn callback, then the interruption occurs regardless of the Interruptible property value.

    • If the running callback is currently executing the waitfor function, then the interruption occurs regardless of the Interruptible property value.

    • Timer objects execute according to schedule regardless of the Interruptible property value.

    When an interruption occurs, MATLAB does not save the state of properties or the display . For example, the handle returned by the gca or gcf command might change when another callback executes.

Callback queuing, specified as 'queue' or 'cancel'. The BusyAction property determines how MATLAB handles the execution of interrupting callbacks. There are two callback states to consider:

  • The running callback is the currently executing callback.

  • The interrupting callback is a callback that tries to interrupt the running callback.

The BusyAction property of the object that owns the interrupting callback determines how MATLAB handles the execution of the interrupting callback. The BusyAction property has two possible values:

  • 'queue' — Put the interrupting callback in a queue to be processed after the running callback finishes execution.

  • 'cancel' — Do not execute the interrupting callback.

Whenever MATLAB invokes a callback, that callback always attempts to interrupt an executing callback (if one exists). The Interruptible property of the object whose callback is executing determines if interruption is allowed. The Interruptible property has two possible values:

  • 'on' — Interruption occurs at the next point where MATLAB processes the queue. This is the default.

  • 'off'BusyAction property (of the object owning the interrupting callback) determines if MATLAB enqueues or ignores the interrupting callback.

Creation and Deletion Control

expand all

This property is read only.

Deletion status of this component, returned as 'off' or 'on'. MATLAB sets the BeingDeleted property to 'on' when the DeleteFcn callback begins execution. The BeingDeleted property remains set to 'on' until the component object no longer exists.

Check the value of the BeingDeleted property to verify that the object is not about to be deleted before querying or modifying it.

Component creation function, specified as one of these values:

  • A function handle.

  • A cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

  • A character vector containing a valid MATLAB expression. For example, 'disp(''hello world'')' calls the disp function. MATLAB evaluates this expression in the base workspace.

This property specifies a callback function to execute when MATLAB creates this component in the app. MATLAB initializes all property values before executing the CreateFcn callback. If you do not specify the CreateFcn property, then MATLAB executes a default creation function.

Use the gcbo function in your CreateFcn code to get the component that is being created.

Setting the CreateFcn property on an existing component has no effect.

    Note:   Do not call copyobj or textwrap (which calls copyobj) inside a CreateFcn. Copying the object causes the CreateFcn callback to execute repeatedly.

Component deletion function, specified as one of these values:

  • A function handle.

  • A cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

  • A character vector containing a valid MATLAB expression. For example, 'disp(''hello world'')' calls the disp function. MATLAB evaluates this expression in the base workspace.

The DeleteFcn property specifies a callback function to execute when MATLAB deletes a component in an app. MATLAB executes the DeleteFcn callback before destroying the properties of the object. If you do not specify the DeleteFcn property, then MATLAB executes a default deletion function.

Use the gcbo function in your DeleteFcn code to access the component that is being deleted.

Identifiers

expand all

This property is read only.

Type of graphics object, returned as 'uidropdown'.

Object identifier, specified as a character vector. You can specify a unique Tag value to serve as an identifier for any component object in your app. When you need access to the object elsewhere in your code, you can use the findobj function to search for the object based on the Tag value.

Example: 'mydropdown'

Data to associate with this component, specified as any array. Specifying UserData can be useful for sharing data values within and across apps you create programmatically.

    Note:   Do not use this property in apps you create with App Designer. For information on sharing data values within and across apps created with App Designer, see Share Data Across Callbacks in App Designer.

Example: [1 2 3]

Example: 'April 21'

Example: struct('value1',[1 2 3],'value2','April 21')

Example: {[1 2 3],'April 21'}

Parent/Child

expand all

Drop-down component parent object, specified as a figure, panel, tab, or button group object.

The parent object must be either a figure created using the uifigure function, or a tab, panel, or button group within such a figure.

Visibility of the drop-down component handle, specified as 'on', 'callback', or 'off'.

This property controls the visibility of the drop-down component handle in its parent's list of children. When a handle is not visible in its parent's list of children, it is not returned by functions that obtain handles by searching the object hierarchy or querying handle properties. These functions include get, findobj, clf, and close. Handles are valid even if they are not visible. If you know an object's handle, you can set and get its properties, and pass it to any function that operates on handles.

HandleVisibility Value Description
'on' The drop-down component handle is always visible.
'callback' The drop-down component handle is visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line. This option blocks access to the drop-down component at the command-line, but allows callback functions to access it.
'off' The drop-down component handle is invisible at all times. This option is useful for preventing unintended changes to the UI by another function. Set the HandleVisibility to 'off' to temporarily hide the handle during the execution of that function.

Introduced in R2016a

Was this topic helpful?

app designer drop down menu

Source: https://lost-contact.mit.edu/afs/inf.ed.ac.uk/group/teaching/matlab-help/R2016b/matlab/ref/dropdownappdesigner-properties.html

Posted by: terrytherend.blogspot.com

0 Response to "app designer drop down menu"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel