|
YCP UI Widget Reference
Back to the widget index
MultiLineEdit
|
multiple line text edit field
|
|
Description
This widget is a multiple line text entry field with a label above it.
An initial text can be provided.
Notice: You can and should set a keyboard shortcut within the
label. When the user presses the hotkey, the corresponding MultiLineEdit
widget will get the keyboard focus.
Arguments
string
|
label
|
label above the field
|
Optional
string
|
initialText
|
the initial contents of the field
|
Special Properties
string
|
Value
|
The text contents as one large string containing newlines.
|
string
|
Label
|
The label above the log text.
|
Sample Usage
`MultiLineEdit( `id( `descr ), "Enter problem & description:", "No problem here." )
Examples
{
UI::OpenDialog(
`VBox(
`MultiLineEdit("Problem &description:"),
`PushButton("&OK")
)
);
UI::UserInput();
UI::CloseDialog();
}
|
|
{
// Build dialog with one multi line edit field and an OK button.
UI::OpenDialog(
`VBox(
`HSpacing(60), // force width
`HBox(
`VSpacing(7), // force height
`MultiLineEdit(`id(`problem),
"Problem &description:", // label
"No problem here") // initial value
),
`PushButton("&OK")
)
);
// Wait for user input.
UI::UserInput();
// Get the input from the MultiLineEdit.
//
// Notice: The return value of UI::UserInput() does NOT return this value!
// Rather, it returns the ID of the widget (normally the PushButton)
// that caused UI::UserInput() to return.
string input = (string) UI::QueryWidget(`id(`problem), `Value);
// Close the dialog.
// Remember to read values from the dialog's widgets BEFORE closing it!
UI::CloseDialog();
// Pop up a new dialog to echo the input.
UI::OpenDialog(
`VBox(
`Label("You entered:"),
`Label(input),
`PushButton("&OK")
)
);
UI::UserInput();
UI::CloseDialog();
}
|
|
{
// Build dialog with MuliLineEdit widget,
// a character counter for the MuliLineEdit's contents as they are typed
// and an OK button.
UI::OpenDialog(
`VBox(
`MultiLineEdit(`id(`problem),
`opt(`notify), // make UI::UserInput() return on every keystroke
"Problem &description:" ),
`HBox(
`Label("Number of characters entered:"),
`Label(`id(`char_count), "0 ")
),
`PushButton(`id(`ok), "&OK")
)
);
any ret = nil;
do
{
// Wait for user input.
//
// Since the MultiLineEdit is in "notify" mode, it, too, will cause
// UI::UserInput() to return upon any single character entered.
ret = UI::UserInput();
if ( ret == `problem ) // User typed some text
{
// Set the `char_count label to the number of characters entered
// into the MultiLineEdit widget.
UI::ChangeWidget(`id(`char_count), `Value,
sformat( "%1", size( (string) UI::QueryWidget(`id(`problem), `Value) ) ) );
}
} while ( ret != `ok );
// Get the input from the MultiLineEdit.
//
// Notice: The return value of UI::UserInput() does NOT return this value!
// Rather, it returns the ID of the widget (normally the PushButton)
// that caused UI::UserInput() to return.
string input = (string) UI::QueryWidget(`id(`problem), `Value);
// Close the dialog.
// Remember to read values from the dialog's widgets BEFORE closing it!
UI::CloseDialog();
// Pop up a new dialog to echo the input.
UI::OpenDialog(
`VBox(
`Label("You entered:"),
`Label(input),
`PushButton("&OK")
)
);
UI::UserInput();
UI::CloseDialog();
}
|
Back to the widget index
|