How can I select multiple entries in a pop-up menu?

17 views (last 30 days)
I created a GUI containing a pop-up menu with four items by typing the following command:
hpop = uicontrol('Style', 'popup', 'String', 'hsv|hot|cool|gray','Position', [20 320 100 50]);
I am able to select one item at a time. I would like to select multiple items at a time.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 31 May 2023
Edited: MathWorks Support Team on 31 May 2023
Pop-up menus open to display a list of choices (defined using the String property) when pressed. When not open, a pop-up menu indicates the current choice. Pop-up menus are useful when you want to provide users with a number of mutually exclusive choices, but do not want to take up the amount of space that a series of radio buttons requires. You must specify a value for the String property.
A List box allows a user to display a list of choices with the ability to select multiple items at the same time. To select multiple items in a list box the Max and Min properties must be defined. If Max - Min > 1, then list boxes allow multiple item selection. If Max - Min <= 1, then list boxes do not allow multiple item selection. Here are the steps:
txt_cell_array = {'line1';'line2';'line3';'line4';'line5'};
h = uicontrol('style','list','max',10,'min',1,'Position',[200 200 80 60],'string',txt_cell_array);
To select multiple items:
1. Click the first item you want to select.
2. Hold the Ctrl key and then click the next item you want to select. Repeat this step until you have selected all the items you want. To select contiguous items, select the first item, hold the Shift key, and then select the last item.
Documentation on the UICONTROL command can be found online at the following URL:

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!