MultiLineEdit — multiple line text edit field
MultiLineEdit
( | string label , |
string
initialValue
) ; |
This widget is a multiple line text entry field with a label above it. An initial text can be provided.
Note: 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.
{ 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(); }
{ UI::OpenDialog( `VBox( `MultiLineEdit( `id( `input ), "Multi Line Edit", "pizza\npasta\npronta" ), `IntField( `id ( `field ), "Limit characters to...", -1, 100, -1 ), `PushButton( `id ( `butt ),"limit input" ), `PushButton( `id ( `exitButton ), "Exit" ) ) ); any ret = nil; ret = UI::UserInput(); while ( ret != `exitButton ) { integer chars = (integer) UI::QueryWidget(`id(`field), `Value); UI::ChangeWidget( `input, `InputMaxLength, chars ); ret = UI::UserInput(); } UI::CloseDialog(); }