Property Name |
Property Value |
choices | A cell array of strings specifying the choices given when the popup is selected. If all the choices are numeric you can use a numeric array instead of the cell array. For example [3 5 7.5] is equivalent to {'3' '5' '7.5'}. |
index | An integer specifying the current choice (default = 1, i.e. the 1st element of the choices cell array). After the popup is set to the specified index, the popup is closed if it had been open. The callback is not normally called when the popup choice is set using the index parameter, however if you specify the negative of the index desired, then the callback will be called after the index is set. |
callbk | A callback to be executed when the popup value is changed. If the callback is defined with a string, then: Occurrences of '@IDX' will be replaced with the popup index. Occurrences of '@STR' will be replaced with the popup string. |
position or pos |
[x y width height] for the opened popup in pixels or normalized units (relative to the figure window).
Note: You might initially get confused because you expect that the closed popup should be somewhere near the (x,y) position in the figure. However this is only true with the default offset (i.e. the closed popup is near the top of the open popup. But when the popup is near the bottom of the screen, one has to choose a zero (or small) offset which means the closed popup is near the bottom of the open popup. In that case the closed popup is not close to (x,y). Two other options may be enabled by making the x or y value negative. Therefore these two lines are equivalent: plt('pop','pos',[-.3 .5 .1 .2],...) plt('pop','pos',[ .3 .5 .1 .2],'offset',0,...) Likewise the following two lines are also equivalent: plt('pop','pos',[.3 -.5 .1 .2],...) plt('pop','pos',[.3 .5 .1 .2],'swap',0,...) In both these examples the second line is preferred for its clarity. Refer to the descriptions of the offset and swap parameters below. Note that you also can make both x and y negative to enable both the offset and swap options. If the position was specified previously you can use a scalar argument to modify just the height component or a two element vector to modify just the width and height components. |
offset | y or [x y] which specifies the location of the closed popup relative to the opened popup. x is set to 0.08 if it is not specified (where 0/1 represent horizontal position of the left/right edges of the opened popup). The meaning of the y variable becomes clear by considering the example where the choices cell array contained 4 elements. Then:
If the offset parameter is not included, then the closed popup will be at the top of the opened popup, i.e. at position |
colorbk | The background color used when the popup is open. (default = [0 .3 .4]); |
colorfr | The foreground color used when the popup is open. (default = [.1 1 .9]) |
enable | -1=invisible, 0=disabled, 1=enabled (default=1) |
swap | Normally a left-click on the pseudo popup control opens the popup to reveal the list of choices
while a right click merely advances to the next choice without opening the popup. Sometimes it is
useful to reverse the roles of the left and right-click - a mode I refer to as the "super-button"
mode. In fact if there is only a single choice, it behaves exactly like a uicontrol button in that
the only effect from clicking on it is that its callback is called. If there are two choices in
the choices cell array, it behaves similarly except that the button text toggles between the two
choices with every click. Usually if there are fewer than four choices, the super-button mode is
more convenient than the regular mode. The super-button mode is selected by including the swap
parameter in the argument list. Often you will want to make the super-button look at least somewhat
like a button by including a box around the super-button text. The color of this box is specified
by the swap parameter. For example swap,'blue' will draw a blue box around
the button text. Or instead of a Matlab color string, you can use an [r g b] color triple. Set the
parameter to zero to use the current foreground color (which defaults to [.1 1 .9]). If the parameter
is missing (which is only possible if the 'swap' argument is at the end) or if the parameter is
set to '' or [] or 'none'
then no box is drawn around the button text.
Sometimes it is useful to be able to toggle the super-button mode on or off interactively. This is
possible with the following quick procedure:
|
hide | A list of objects to hide before opening the popup. When the popup is later closed, these objects are shown again (unless they were hidden before the popup opened). The hide parameter is used to remove the distraction of objects that overlap or are too close to the popup list. If there is a zero in the list, before the list is used the zero will be replaced with the handle (or handles) of the plot grid lines. (This is convenient because grid lines are the most common object to overlap with opened popups.) Also setting the hide parameter to '' or [] or not supplying a parameter at all (only possible if the 'hide' argument is the last one) is equivalent to setting the parameter to zero. |
interp | 'none' or 'tex' (default='none') |
label | {'LabelString', offset, 'Property1',Value1,'Property2',Value2, ...}
A label for the popup will be created as a text object in the same axis that is used to display the popup choices and will contain the string 'LabelString' (the first element of the cell array argument). The 2nd element of the cell array is a complex number containing the offset for the label position in pixels from the closed popup. (The real part is the x offset and the imaginary part is the y offset). For example if the 2nd element of the cell array is -10+20i, then the label will be positioned 10 pixels to the left and 20 pixels above the closed popup. The remaining cell array elements (if any) must contain property/value pairs, and the properties must be valid text object property names. The specified properties will be applied to the closed popup text string. Specifying an offset of '' or [] is equivalent to specifying the number 5 for this cell array element. (i.e. the default offset is 5 pixels to the left.) Instead of specifying a cell array for the label argument, you may also specify a string. For example, the argument 'LabelString' is equivalent to {'LabelString',''}. Since the default offset is usually sufficient, it turns out that this shorter form is used far more often than the cell array parameter. |
labely | This behaves just like the label parameter above except for the fact that the default offset when it isn't specified is 16i (instead of 5 as is used by the label parameter). This is the usual offset needed for placing the popup label directly above the closed popup text. |
***** | If a property name is given which isn't in the list above then the property is applied to the popup text object itself. (It must be a valid text property.) The text color ('color') is usually set this way, however if that property is not specified, the default color is [1 1 .4]. |
H = plt('pop', 'Property1',Value1, 'Property2',Value2,...) | The property names allowed and the interpretation of the property values are shown in the table above. You many use as many or as few properties as you need in whatever order you choose. If you favor clarity over conciseness, there is no need to consider the alternate forms shown below. |
H = plt('pop', [x y width height], {'choice1', ... 'choiceN'}, 'Property3',Value3,...) | Both the 'position' and the 'choices' properties are required, so for conciseness you may omit those
property names if the property values appear first and in this order. A command such as this equivalent to this longer form: H = plt('pop','pos',[x y width height],'choices', Note that in any of these commands you may use either pixel or normalized units. (You aren't required to included the 'units' property since plt can figure out this property from the size of the numbers in the position vector.) |
H = plt('pop', [x y width height], @cb,'Property4',Value4,...) | This command is equivalent to: H = plt('pop',[x y width height],v,'callbk',@cb,'Property4',Value4,...) Since most pseudo popup objects will be created with a callback, the 'callbk' property name can also be omitted by specifying the callback immediately after the position and choices arguments. In this example the callback is specified by a function handle (@cb) but it may also be specified as a string. Property names other than these three ('pos', 'choices', 'callbk') may not be omitted. |
plt('pop',H, 'Property1',Value1, 'Property2',Value2,...) | The specified property values are applied to the popup pseudo object identified by handle H. The property names may include the ones listed in the table shown at the top of this page as well as standard Matlab property names of the popup text object. To see a list of the allowed property names and values, type set(text(0,0,'')) in the command window. |
plt('pop',H,'get','string') | returns the currently selected element of the choices cell array. Equivalent to the shorter command: get(H,'string') |
plt('pop',H,'get','axis') | returns the handle of the axis used to display the opened popup. |
plt('pop',H,'get','choices') | returns the cell array of choices that was set via the 'choices' parameter |
plt('pop',H,'get','index') | returns the index number of the specified edit pseudo object (between 1 and the
length of the choices cell array).
For conciseness, this command may also be written without the last argument:
|
plt('pop',H,'get','callbk') | returns the function handle or string that was set via the 'callbk' parameter |
plt('pop',H,'get','offset') | returns the number or vector that was specified via the 'offset' parameter |
plt('pop',H,'get','colorfr') | returns the 3 element vector or color string that was specified via the 'colorfr' parameter |
plt('pop',H,'get','enable') | returns -1/0/1 if the pseudo object is hidden/disabled/enabled |
plt('pop',H,'get','hide') | returns the vector of handles that was set via the 'hide' parameter |
plt('pop',H,'get','interp') | returns the string that was set via the 'interp' parameter |
plt('pop',H,'get','label') | returns the label handle |
plt('pop',H,'get','swap') | returns true if the swap (super-button) mode is selected. |
plt('pop',H,'get','cell') | returns an 11 element cell array that is a concatenation of the
previous 11 get commands: {axis choices index callbk offset colorfr enable hide interp label}. Note that this does not include the first get command ('string') listed above. Also 'cell' in this call may be replaced by any string other than one of the other 12 valid 'get' arguments. |
plt('pop',H,'open') | opens the popup revealing the popup choices. |
figure('color','black'); % create a figure to hold the 3 pseudo popups created by the next line
h = plt('pop',arrange(3),prin('{choice%d!row}',1:6),'label',{'first' 'second' 'third''});
plt('pop',h,'index',{6 5 4}); % Change the popup settings to choice 6,5,4 respectively.
plt('pop',h) % verify this worked by displaying the 3 index values
plt('pop',h,'get','string') % verify this worked by displaying the 3 popup strings
plt('pop',h,'get','cell') % display a 3x11 cell array. Row k shows all information for popup k
g = plt('pop',h,'get','label'); % get the handles of the popup labels
set([h;g],'vis','off'); % make all four pseudo popups invisible
set([h;g],'vis','on'); % make them visible again