Method dialog.showInput
Overload
Shows dialog with a text edit field and gets that text.
public static bool showInput(out string s, string text1 = null, string text2 = null, DEdit editType = DEdit.Text, string editText = null, Strings comboItems = default, DFlags flags = 0, AnyWnd owner = default, string expandedText = null, string footer = null, string title = null, DControls controls = null, Coord x = default, Coord y = default, screen screen = default, int secondsTimeout = 0, Action<DEventArgs> onLinkClick = null, string buttons = "1 OK|2 Cancel", Action<DEventArgs> onButtonClick = null)
Parameters
s (string)
Variable that receives the text. |
text1 (string)
Main instruction. Bigger font. |
text2 (string)
Read-only text below main instruction, above the edit field. |
editType (DEdit)
Edit field type. It can be simple text (default), multiline, number, password or combo box. |
editText (string)
Initial edit field text. |
comboItems (Strings)
Combo box items used when editType is DEdit.Combo. |
flags (DFlags) |
owner (AnyWnd)
Owner window. See dialog.SetOwnerWindow. |
expandedText (string)
Text that the user can show and hide. |
footer (string)
Text at the bottom of the dialog. Icon can be specified like |
title (string)
Title bar text. If omitted, |
controls (DControls)
Can be used to add more controls and later get their values: checkbox, radio buttons. |
x (Coord)
X position in dialog.Screen. If default - screen center. Examples: |
y (Coord)
Y position in dialog.Screen. If default - screen center. |
screen (screen)
dialog.Screen. Examples: |
secondsTimeout (int)
If not 0, after this time (seconds) auto-close the dialog and return dialog.Timeout. |
onLinkClick (Action<DEventArgs>)
Enables hyperlinks in small-font text. A link-clicked event handler function, like with dialog.show. |
buttons (string)
Buttons. A list of strings |
onButtonClick (Action<DEventArgs>)
A button-clicked event handler function. See examples. |
Returns
bool
|
Exceptions
Win32Exception
Failed to show dialog. |
Remarks
This function allows you to use many dialog features, but not all. Alternatively you can create a dialog class instance, call dialog.SetEditControl or use the controls parameter, set other properties and call ShowDialog.
Examples
Simple.
string s;
if(!dialog.showInput(out s, "Example")) return;
print.it(s);
if(!dialog.showInput(out var s2, "Example")) return;
print.it(s2);
With checkbox.
var con = new DControls { Checkbox = "Check" };
if(!dialog.showInput(out var s, "Example", "Comments.", controls: con)) return;
print.it(s, con.IsChecked);
With onButtonClick function.
int r = 0;
dialog.showInput(out string s, "Example", buttons: "OK|Cancel|Later", onButtonClick: e => r = e.Button);
print.it(r);
if(!dialog.showInput(out string s, "Example", flags: DFlags.CommandLinks, buttons: "OK|Cancel|10 Set text", onButtonClick: e => {
if(e.Button == 10) { e.EditText = "text"; e.DontCloseDialog = true; }
})) return;
if(!dialog.showInput(out string s2, "Example", "Try to click OK while text is empty.", onButtonClick: e => {
if(e.Button == 1 && e.EditText.NE()) {
dialog.show("Text cannot be empty.", owner: e.hwnd);
e.d.EditControl.Focus();
e.DontCloseDialog = true;
}
})) return;