Prev: Spherical Axes
Next: Unfortunately this didn't work :(
From: John D'Errico on 14 Apr 2010 09:40 Try this in matlab. I wanted to create a listbox that would allow multiple selections. In this example, I had two choices in the listbox. So logically, I set 'min' to 1, and max to 2. If I set the 'value' property to either 1 or 2, it works correctly. But if I wish to allow the user to select both options, with both selected as the default, one would think it logical to set the value property to [1 2]. H = figure; Hlb = uicontrol('Parent',H, ... 'Units','normalized', ... 'BackgroundColor',[1 1 1], ... 'Position',[.1 .1 .5 .5], ... 'String',{'Now is the time' 'For all good men'}, ... 'Style','listbox', ... 'Min',1, ... 'Max',2, ... 'Value',[1 2]); Warning: single-selection listbox control requires a scalar Value Control will not be rendered until all of its parameter values are valid Warning: single-selection listbox control requires a scalar Value Control will not be rendered until all of its parameter values are valid As you see, the uicontrol will not render. Surely there is no problem with the uicontrol call as I have it? The answer is obvious. In order for MATLAB to allow TWO options selected and render the uicontrol, you need to set the 'max' property to 3. NOT 2! Yeah. Obvious. Clear as mud. There is no problem IF there are 3 strings in the listbox. as then 'max' - 'min' is greater than 1. The documentation tells you this, if you look long enough. I'd still call it a bug, as it ensures that you will have a problem if you just read the help whenever you end up with exactly two options in the listbox. John
|
Pages: 1 Prev: Spherical Axes Next: Unfortunately this didn't work :( |