|
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")
)
);
UserInput();
CloseDialog();
})
|
UI(``{
// Build dialog with one multi line edit field and an OK button.
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.
UserInput();
// Get the input from the MultiLineEdit.
//
// Notice: The return value of UserInput() does NOT return this value!
// Rather, it returns the ID of the widget (normally the PushButton)
// that caused UserInput() to return.
string input=QueryWidget(`id(`problem), `Value);
// Close the dialog.
// Remember to read values from the dialog's widgets BEFORE closing it!
CloseDialog();
// Pop up a new dialog to echo the input.
OpenDialog(
`VBox(
`Label("You entered:"),
`Label(input),
`PushButton("&OK")
)
);
UserInput();
CloseDialog();
})
|
|
UI(``{
// Build dialog with MuliLineEdit widget,
// a character counter for the MuliLineEdit's contents as they are typed
// and an OK button.
OpenDialog(
`VBox(
`MultiLineEdit(`id(`problem),
`opt(`notify), // make 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
// UserInput() to return upon any single character entered.
ret = UserInput();
if ( ret == `problem ) // User typed some text
{
// Set the `char_count label to the number of characters entered
// into the MultiLineEdit widget.
ChangeWidget(`id(`char_count), `Value,
sformat( "%1", size( QueryWidget(`id(`problem), `Value) ) ) );
}
} while ( ret != `ok );
// Get the input from the MultiLineEdit.
//
// Notice: The return value of UserInput() does NOT return this value!
// Rather, it returns the ID of the widget (normally the PushButton)
// that caused UserInput() to return.
string input=QueryWidget(`id(`problem), `Value);
// Close the dialog.
// Remember to read values from the dialog's widgets BEFORE closing it!
CloseDialog();
// Pop up a new dialog to echo the input.
OpenDialog(
`VBox(
`Label("You entered:"),
`Label(input),
`PushButton("&OK")
)
);
UserInput();
CloseDialog();
})
|
Back to the widget index
|