Show / Hide Table of Contents

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 "i|Text", where i is: x error, ! warning, i info, v shield, a app.

title  (string)

Title bar text. If omitted, null or "", uses dialog.options.defaultTitle.

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: 10, ^10 (reverse), .5f (fraction).

y  (Coord)

Y position in dialog.Screen. If default - screen center.

screen  (screen)

dialog.Screen. Examples: screen.ofMouse, screen.index(1).

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 "id text" separated by |, like "1 OK|2 Cancel|10 Browse...". See dialog.show. Note: this function returns true only when clicked button with id 1. Usually custom buttons are used with onButtonClick function, which for example can get button id or disable closing the dialog.

onButtonClick  (Action<DEventArgs>)

A button-clicked event handler function. See examples.

Returns
bool

true if selected OK (or a custom button with id 1).

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;