Difference between revisions of "AskMsgChoice"

(encouragement of community design)
m
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:User-interface functions]]
 
[[Category:User-interface functions]]
  
'''Not Implemented!!'''  ''This is a proposed function, which we have placed here on the Wiki in advance of its eventual implementation so that interested parties have an opportunity to contribute to is specification before we actually implement it.  It has not yet been targetted for a specific release. Most likely it will end up being targetted for Analytica 4.6 or 4.7.''
 
  
''As an Analytica user, you are welcome to contribute your ideas for this feature here -- either by directly editing this page if you feel you have a well thought-out spec, or on the discussion tab if you have less formulated ideas.  This is also an experiment for us to see how community participation in the design of a feature might work out.''
+
== AskMsgChoice(question, ''title'', optionList'', default, showAll, comboBox'') ==
 +
A [[Dialog Functions|Dialog Function]] that creates a dialog box asking the user to select from a drop-down of possible choices.  
  
= AskMsgChoice(question,title,optionsList'',default,showAll,comboBox'') =
+
Parameters:
 +
;<code>«question»</code> : Text that appears in the dialog body itself, above the choice pulldown.
 +
;<code>«title»</code>: The caption for the dialog.
 +
;<code>«optionList»</code>: An unindexed list, or a 1-D array, containing the possible options.  It can be an expression that computes such a list.  Numbers are coerced to text using the number format for the variable currently being evaluated.
 +
;<code>«default»</code>: (optional): The item from the choice list that should be selected initially. 
 +
;<code>«showAll»</code> : (optional boolean, default: false): Indicates whether the "All" option should appear on the dropdown.
 +
;<code>«comboBox»</code> : (optional boolean, default:false): When this is true, a ComboBox is displayed.  The «optionList» is a dropdown with suggested values, but any value may be typed.  When true, «default» does not have to be in the «optionList».
 +
 
 +
The result returned is the selected label from «optionList», unless "All" is selected, in which case the result is the same value supplied as «optionList».
 +
 
 +
The dialog includes an '''OK''' and a '''Cancel''' button.  When '''Cancel''' is pressed, the current in-process computation is aborted.
  
When evaluated, a pop-up dialog asks the user to select from a drop-down of possible choices.  
+
When called from [[ADE]], this function does not present any UI, and simply returns the default selection.
  
Parameters:
+
When «comboBox» is not specified, or is false, a straight pull-down is displayedIn this case, «default» must be in «optionList» or be the textual value <code>"All"</code>, or an error is issuedWhen «default» is omitted, it defaults to "All" when «showAll» is true, or to the first selection otherwise.
* «question» : Text that appears in the dialog body itself, above the choice pulldown.
 
* «title» : The caption for the dialog.
 
* «optionsList»: An unindex list, or a 1-D array, containing the possible optionsIt can be an expression that computes such a list.  Numbers are coerced to text using the number format for the variable currently being evaluated.
 
* «default» (optional): The item from the choice list that should be selected initially. 
 
* «showAll» : (optional boolean, default: false): Indicates whether the "All" option should appear on the dropdown.
 
* «comboBox» : (optional boolean, default:false): When this is true, a ComboBox is displayedThe «optionsList» is a dropdown with suggested values, but any value may be typed.  When true, «default» does not have to be in the «optionsList».
 
  
The result returned is the selected label from «optionsList», unless "All" is selected, in which case the result is the same value supplied as «optionsList».
+
When «comboBox» is true, a combo box is displayed, which contains both a single-line text entry field and a pulldown.  The pulldown serves as list of suggestions, but any (single-line) of text may be entered.  When an item on the pulldown is selected, its value appears in the text field.  The «default» value does NOT need to be in «optionList».  When omitted, "All" is selected if «showAll» is true, otherwise the initial field is blank.
  
The dialog includes an OK and a Cancel buttonWhen Cancel is pressed, the current in-process computation is aborted.
+
When «default» is the textual value <code>"All"</code>, and «showAll» is true, then the "All" option is selected ''unless'' the textual value <code>"All"</code> exists in «optionList».  In that case, the item is selected rather than the "All" optionThis special case creates a special case behavior, which is undesirable, but it also is intuitive.
  
When called from ADE, this function does not present any UI, and simply returns the default selection.
+
== Examples ==
 +
:<code>AskMsgChoice("What is your favorite color?", "Select color", ["Black", "Blue", "Brown", "Cyan", "Green", "Orange", "Red", "White", "Yellow"], default: "Green", comboBox: true)</code>
  
When «comboBox» is not specified, or is false, a straight pull-down is displayed.  In this case, «default» must be in «optionsList» or be the textual value <code>"All"</code>, or an error is issued.  When «default» is omitted, it defaults to "All" when «showAll» is true, or to the first selection otherwise.
+
User can select a color or type something else.  
  
When «comboBox» is true, a combobox is displayed, which contains both a single-line text entry field and a pulldown.  The pulldown serves as list of suggestions, but any (single-line) of text may be entered.  When an item on the pulldown is selected, its value appears in the text field.  The «default» value does NOT need to be in «optionsList».  When omitted, "All" is selected if «showAll» is true, otherwise the initial field is blank.
+
:[[Image:AskMsgChoice-combo.png]]
  
When «default» is the textual value <code>"All"</code>, and «showAll» is true, then the "All" option is selected ''unless'' the textual value <code>"All"</code> exists in «optionsList». In that case, the item is selected rather than the "All" option.  This special case creates a special case behavior, which is undesirable, but it also is intuitive.
+
:<code>AskMsgChoice("What is your favorite color?", "Select color", ["Black", "Blue", "Brown", "Cyan", "Green", "Orange", "Red", "White", "Yellow"], default: "Green")</code>
  
Design question: Do we disallow <code>showAll:true</code> and <code>comboBox:true</code>?  If not, how should "All" be displayed in the text box when selected?  One option is as "«All»", since most people don't type those delimiters. Another is to have the control turn into a pulldown (without the text field) while All is selected. Related question: What if <code>default:"All"</code> and <code>comboBox:true</code>?  Should "All" be interpreted specially?
+
User selects from the pulldown of possible choices.  
  
The width of the dialog and the pulldown/text control adapts to the length of the available options.  The pulldown appears wide enough to accommodate both the longest text in «optionsList» and the «default» value up to a point.  When the length of these would result in a dialog exceeding the lesser of 1000 pixels or the width of the monitor, then the width is limited to that amount.  In the pure pulldown case, the text of the displayed suggestion is truncated.  The width of the popup does not need to be constrained by this same limit, but should be fully visible on the monitor, truncating when necessary.
+
:[[Image:AskMsgChoice-pulldown.png]]
  
= Examples =
+
== From ADE ==
 +
When evaluated in [[ADE|the Analytica Decision Engine (ADE)]], it calls [[IAdeUICallbacks::AskMsgChoice]](...). From within that callback, the parent application can display a dialog, collect input from the end-user, and return that as the return value. To receive the callback, the parent application must have previously registered the callback with ADE using [[CAEngine::SetCallbackObject]]( ).
  
[[AskMsgChoice]]("What is your favorite color?", "Select color", ['Black','Blue','Brown','Cyan','Green','Orange','Red','White','Yellow'],
+
==History==
                  default:'Green', comboBox:true)
+
This function was introduced in [[Analytica 4.5]].
  
= See Also =
+
The ADE callback was introduced in [[Analytica 4.6|ADE 4.6]].
  
 +
== See Also ==
 +
* [[Dialog Functions]]
 
* [[AskMsgNumber]]
 
* [[AskMsgNumber]]
 
* [[AskMsgText]]
 
* [[AskMsgText]]
 
* [[Choice]]
 
* [[Choice]]
 
* [[MsgBox]]
 
* [[MsgBox]]
 +
* [[Creating Interfaces for End Users]]

Latest revision as of 19:56, 11 March 2022


AskMsgChoice(question, title, optionList, default, showAll, comboBox)

A Dialog Function that creates a dialog box asking the user to select from a drop-down of possible choices.

Parameters:

«question»
Text that appears in the dialog body itself, above the choice pulldown.
«title»
The caption for the dialog.
«optionList»
An unindexed list, or a 1-D array, containing the possible options. It can be an expression that computes such a list. Numbers are coerced to text using the number format for the variable currently being evaluated.
«default»
(optional): The item from the choice list that should be selected initially.
«showAll»
(optional boolean, default: false): Indicates whether the "All" option should appear on the dropdown.
«comboBox»
(optional boolean, default:false): When this is true, a ComboBox is displayed. The «optionList» is a dropdown with suggested values, but any value may be typed. When true, «default» does not have to be in the «optionList».

The result returned is the selected label from «optionList», unless "All" is selected, in which case the result is the same value supplied as «optionList».

The dialog includes an OK and a Cancel button. When Cancel is pressed, the current in-process computation is aborted.

When called from ADE, this function does not present any UI, and simply returns the default selection.

When «comboBox» is not specified, or is false, a straight pull-down is displayed. In this case, «default» must be in «optionList» or be the textual value "All", or an error is issued. When «default» is omitted, it defaults to "All" when «showAll» is true, or to the first selection otherwise.

When «comboBox» is true, a combo box is displayed, which contains both a single-line text entry field and a pulldown. The pulldown serves as list of suggestions, but any (single-line) of text may be entered. When an item on the pulldown is selected, its value appears in the text field. The «default» value does NOT need to be in «optionList». When omitted, "All" is selected if «showAll» is true, otherwise the initial field is blank.

When «default» is the textual value "All", and «showAll» is true, then the "All" option is selected unless the textual value "All" exists in «optionList». In that case, the item is selected rather than the "All" option. This special case creates a special case behavior, which is undesirable, but it also is intuitive.

Examples

AskMsgChoice("What is your favorite color?", "Select color", ["Black", "Blue", "Brown", "Cyan", "Green", "Orange", "Red", "White", "Yellow"], default: "Green", comboBox: true)

User can select a color or type something else.

AskMsgChoice-combo.png
AskMsgChoice("What is your favorite color?", "Select color", ["Black", "Blue", "Brown", "Cyan", "Green", "Orange", "Red", "White", "Yellow"], default: "Green")

User selects from the pulldown of possible choices.

AskMsgChoice-pulldown.png

From ADE

When evaluated in the Analytica Decision Engine (ADE), it calls IAdeUICallbacks::AskMsgChoice(...). From within that callback, the parent application can display a dialog, collect input from the end-user, and return that as the return value. To receive the callback, the parent application must have previously registered the callback with ADE using CAEngine::SetCallbackObject( ).

History

This function was introduced in Analytica 4.5.

The ADE callback was introduced in ADE 4.6.

See Also

Comments


You are not allowed to post comments.